Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ASD_Task_3.depend
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,32 @@
"operation.h"
"my_data.h"

1582346390 source:d:\kuliah\semester 2\asd_task_3\list.cpp
"list.h"
"my_data.h"
<iostream>

1582345192 d:\kuliah\semester 2\asd_task_3\list.h
<iostream>
"my_data.h"

1581926406 d:\kuliah\semester 2\asd_task_3\my_data.h
<iostream>

1582347753 source:d:\kuliah\semester 2\asd_task_3\main.cpp
<iostream>
"list.h"
"operation.h"
"my_data.h"

1581918600 d:\kuliah\semester 2\asd_task_3\operation.h
"list.h"

1582383090 source:d:\kuliah\semester 2\asd_task_3\my_data.cpp
"my_data.h"

1582382247 source:d:\kuliah\semester 2\asd_task_3\operation.cpp
"list.h"
"operation.h"
"my_data.h"

28 changes: 14 additions & 14 deletions ASD_Task_3.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,39 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" />
<File name="my_data.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="operation.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="496" topLine="7" />
<Cursor1 position="58" topLine="0" />
</Cursor>
</File>
<File name="operation.cpp" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="my_data.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="288" topLine="0" />
<Cursor1 position="418" topLine="0" />
</Cursor>
</File>
<File name="list.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="operation.cpp" open="1" top="1" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2862" topLine="116" />
<Cursor1 position="1613" topLine="53" />
</Cursor>
</File>
<File name="main.cpp" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="list.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1006" topLine="0" />
<Cursor1 position="532" topLine="0" />
</Cursor>
</File>
<File name="my_data.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="list.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="774" topLine="0" />
<Cursor1 position="542" topLine="34" />
</Cursor>
</File>
<File name="list.h" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="688" topLine="17" />
<Cursor1 position="1311" topLine="77" />
</Cursor>
</File>
<File name="operation.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="my_data.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="207" topLine="0" />
<Cursor1 position="454" topLine="9" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added bin/Debug/ASD_Task_3.exe
Binary file not shown.
108 changes: 74 additions & 34 deletions list.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
#include "list.h"
#include "my_data.h"
#include <iostream>
using namespace std;

void createList(List &L) {
/**
* FS : set first(L) and last(L) with Null
*/
//-------------your code here-------------
your code here


L.first = NULL;
L.last = NULL;
//----------------------------------------
}

Expand All @@ -19,9 +20,13 @@ address allocate(infotype x) {

address P;
//-------------your code here-------------
your code here


P = new elmlist;
info(P).ID = x.ID;
info(P).name = x.name;
info(P).rank = x.rank;
info(P).score = x.score;
next(P) = NULL;
prev(P) = NULL;
//----------------------------------------
return P;
}
Expand All @@ -31,9 +36,7 @@ void deallocate(address &P) {
* FS : delete element pointed by P
*/
//-------------your code here-------------
your code here


delete P;
//----------------------------------------
}

Expand All @@ -43,9 +46,14 @@ void insertFirst(List &L, address P) {
* FS : element pointed by P became the first element in List L
*/
//-------------your code here-------------
your code here


if (L.first != NULL){
P->next = L.first;
prev(L.first) = P;
L.first = P;
}else{
L.first = P;
L.last = P;
}
//----------------------------------------
}

Expand All @@ -55,9 +63,14 @@ void insertLast(List &L, address P) {
* FS : element pointed by P became the last element in List L
*/
//-------------your code here-------------
your code here


if (L.first!=NULL){
P->prev = L.last;
next(L.last) = P;
L.last = P;
}else{
L.last = P;
L.first = P;
}
//----------------------------------------
}

Expand All @@ -70,9 +83,15 @@ address findElm(List L, infotype x) {

address P;
//-------------your code here-------------
your code here


P = L.first;
if (L.first!=NULL){
while (P != NULL && info(P).ID != x.ID)
{
P = P -> next;
}
}else{
P=NULL;
}
//----------------------------------------
return P;
}
Expand All @@ -83,10 +102,15 @@ void deleteFirst(List &L, address &P) {
* FS : first element in List L is removed and is pointed by P
*/
//-------------your code here-------------
your code here



P = L.first;
if (L.first!=last(L)){
L.first = next(P);
next(P) = NULL;
prev(L.first)=NULL;
}else {
L.first = NULL;
L.last = NULL;
}
//----------------------------------------
}

Expand All @@ -96,10 +120,15 @@ void deleteLast(List &L, address &P) {
* FS : last element in List L is removed and is pointed by P
*/
//-------------your code here-------------
your code here



P = L.last;
if (L.last!=first(L)){
L.last = prev(P);
prev(P) = NULL;
next(L.last)=NULL;
}else {
L.first = NULL;
L.last = NULL;
}
//----------------------------------------
}

Expand All @@ -109,9 +138,16 @@ void printInfo(List L) {
* call the view_data function from my_data.h to print the info
*/
//-------------your code here-------------
your code here


address P=first(L);
if (P==NULL){
cout<<"Data Tidak Ada.."<<endl;
}else{
while (P!=NULL){
view_data(info(P));
P = next(P);
}
}
cout<<endl;
//----------------------------------------
}

Expand All @@ -123,8 +159,10 @@ void insertAfter(List &L, address Prec, address P) {
* pointed by pointer Prec
*/
//-------------your code here-------------
your code here

P->next = Prec->next;
P->prev = Prec;
prev(next(Prec)) = P;
Prec->next = P;
//----------------------------------------

}
Expand All @@ -135,9 +173,11 @@ void deleteAfter(List &L, address Prec, address &P) {
* is removed and pointed by pointer P
*/
//-------------your code here-------------
your code here


P = next(Prec);
next(Prec) = next(P);
prev(next(P)) = Prec;
next(P) = NULL;
prev(P) = NULL;
//----------------------------------------
}

14 changes: 8 additions & 6 deletions list.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ using namespace std;
* prev : address
* >
*
* Type List : <
* first : address
* last : address
* Type List : <
* first : address
* last : address
* >
*
**/
Expand All @@ -37,14 +37,16 @@ typedef struct elmlist *address;

struct elmlist{
//------------- your code here -----------

infotype info;
address next;
address prev;
//----------------------------------------
};

struct List{
//------------- your code here -----------


address first;
address last;
//----------------------------------------
};

Expand Down
62 changes: 59 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ int main() {
}

void mainMenu() {
address P;
address P,R;
infotype X;
mytype idpeserta;
/**
* IS : List has been created
* PR : prints menu to user
Expand Down Expand Up @@ -50,8 +51,63 @@ void mainMenu() {
switch(choice) {
case 1:
X = create_data();
P = allocate(X);
insertFirst(L,P)
insertAndSort(L,X);
cout<<endl;
break;
case 2:
cout<<"Data semua member: "<<endl;
printInfo(L);
cout<<endl;
break;
case 3:
cout<<"Masukkan ID member yang ingin dilihat: ";
cin>>idpeserta.ID;
P= findElm(L, idpeserta);
if(P!=NULL){
view_data(info(P));
}else{
cout << "ID yang anda cari TIDAK ADA.." << endl;
}
cout<<endl;
break;
case 4:
cout << "Masukkan ID member yang ingin di edit: ";
cin >> idpeserta.ID;
P = findElm(L, idpeserta);
if (P!=NULL){
cout<<"Silahkan mengedit data member: "<<endl;
edit_data(info(P));
cout<<"Data berhasil diperbarui"<<endl;
}else{
cout<<"ID yang anda cari TIDAK ADA.."<<endl;
}
cout<<endl;
break;
case 5:
cout << "Masukkan ID member yang ingin di hapus: ";
cin >> idpeserta.ID;
P = findElm(L, idpeserta);
if (P!=NULL){
deletebyID(L, idpeserta.ID);
cout<<"Data berhasil dihapus.."<<endl;
}else{
cout<<"Data Tidak ada.."<<endl;
}
cout<<endl;
break;
case 6:
savePassedMember(L, L_passed);
cout<<"Pemindahan Member yang LULUS selesai.."<<endl;
cout<<endl;
break;
case 7:
cout<<"Data Mahasiswa yang LULUS:"<<endl;
printInfo(L_passed);
cout<<endl;
break;
}
if (choice == 0)
{
break;
}
} while(true);
Expand Down
Loading