diff --git a/ASD_Task_4.depend b/ASD_Task_4.depend index a544662..ed4fe06 100644 --- a/ASD_Task_4.depend +++ b/ASD_Task_4.depend @@ -19,3 +19,23 @@ "player.h" +1583564997 source:c:\users\azizah cahya\documents\github\asd_task_4\main.cpp + "player.h" + "list.h" + + +1583558502 c:\users\azizah cahya\documents\github\asd_task_4\player.h + "list.h" + +1583561694 c:\users\azizah cahya\documents\github\asd_task_4\list.h + + + + +1583570330 source:c:\users\azizah cahya\documents\github\asd_task_4\player.cpp + "player.h" + + +1583564795 source:c:\users\azizah cahya\documents\github\asd_task_4\list.cpp + "list.h" + diff --git a/ASD_Task_4.layout b/ASD_Task_4.layout index 5ec49e7..7b65762 100644 --- a/ASD_Task_4.layout +++ b/ASD_Task_4.layout @@ -2,29 +2,29 @@ - + - + - + - + - + - + - + - + - + diff --git a/bin/Debug/ASD_Task_4.exe b/bin/Debug/ASD_Task_4.exe new file mode 100644 index 0000000..14fd957 Binary files /dev/null and b/bin/Debug/ASD_Task_4.exe differ diff --git a/list.cpp b/list.cpp index 847a957..987d709 100644 --- a/list.cpp +++ b/list.cpp @@ -5,7 +5,7 @@ void createList(List &L) { * FS : first(L) diset Nil */ //------------- YOUR CODE HERE ------------- - + first(L) = NULL; //---------------------------------------- } @@ -17,7 +17,10 @@ address allocate(infotype x) { address P = NULL; //------------- YOUR CODE HERE ------------- - + P = new elmlist; + info(P).ID = x.ID; + info(P).location = x.location; + info(P).name = x.name; //---------------------------------------- return P; } @@ -27,7 +30,7 @@ void deallocate(address &P) { * FS : menghapus elemen yang ditunjuk oleh P (delete) */ //------------- YOUR CODE HERE ------------- - + delete P; //---------------------------------------- } @@ -37,7 +40,17 @@ void insertFirst(List &L, address P) { * FS : elemen yang ditunjuk P menjadi elemen pertama pada List L */ //------------- YOUR CODE HERE ------------- - + if (first(L) == NULL){ + first(L) = P; + next(first(L)) = P; + prev(first(L)) = P; + }else{ + next(P) = first(L); + next(prev(first(L))) = P; + prev(P) = prev(first(L)); + prev(first(L)) = P; + first(L) = P; + } //---------------------------------------- } @@ -47,7 +60,17 @@ void insertLast(List &L, address P) { * FS : elemen yang ditunjuk P menjadi elemen terakhir pada List L */ //------------- YOUR CODE HERE ------------- - + if(first(L) == NULL){ + first(L) = P; + next(first(L)) = P; + prev(first(L)) = P; + }else { + next(P) = first(L); + prev(P) = prev(first(L)); + next(prev(first(L))) = P; + prev(first(L)) = P; + + } //---------------------------------------- } @@ -60,7 +83,18 @@ address findElmByID(List L, infotype x) { address P = NULL; //------------- YOUR CODE HERE ------------- - + if(first(L) == NULL){ + cout<<"List Kosong"<>x.ID; + P = findElmByID(L, x); + if(P != NULL){ + cout<<"music found"<>x.name; + cin>>x.ID; deleteMusicByID(L, x); cout<<"press enter";getche(); break; diff --git a/obj/Debug/list.o b/obj/Debug/list.o new file mode 100644 index 0000000..40c11f4 Binary files /dev/null and b/obj/Debug/list.o differ diff --git a/obj/Debug/main.o b/obj/Debug/main.o new file mode 100644 index 0000000..6cf7834 Binary files /dev/null and b/obj/Debug/main.o differ diff --git a/obj/Debug/player.o b/obj/Debug/player.o new file mode 100644 index 0000000..9f1eb00 Binary files /dev/null and b/obj/Debug/player.o differ diff --git a/player.cpp b/player.cpp index 31ef288..d1904e7 100644 --- a/player.cpp +++ b/player.cpp @@ -12,7 +12,6 @@ void printInfo(List L) { * PR : menampilkan informasi ID, nama, dan lokasi file * YOU DON'T NEED TO MODIFY THIS */ - address Q = first(L); do { cout<<"name : "< 0){ + P = first(L); + random = randomInt(i); + int k = 1; + while(k != random ){ + P = next(P); + k = k + 1; + } + deleteAfter(L, prev(P), Q); + insertLast(L, Q); + i = i - 1; + } - cout<<"UNDER MAIN TENIS"<