Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1301194066 || MUH. FACHRUL HIDAYAT || IF-43-05 #165

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
28 changes: 28 additions & 0 deletions ASD_Task_3.depend
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,31 @@
"operation.h"
"my_data.h"

1582369741 source:c:\users\asus\documents\github\asd_task_3\main.cpp
<iostream>
"list.h"
"operation.h"
"my_data.h"

1581957108 c:\users\asus\documents\github\asd_task_3\list.h
<iostream>
"my_data.h"

1582367462 c:\users\asus\documents\github\asd_task_3\my_data.h
<iostream>

1581956906 c:\users\asus\documents\github\asd_task_3\operation.h
"list.h"

1582370026 source:c:\users\asus\documents\github\asd_task_3\list.cpp
"list.h"
"my_data.h"

1582364652 source:c:\users\asus\documents\github\asd_task_3\my_data.cpp
"my_data.h"

1582369763 source:c:\users\asus\documents\github\asd_task_3\operation.cpp
"list.h"
"operation.h"
"my_data.h"

26 changes: 13 additions & 13 deletions ASD_Task_3.layout
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
<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="list.cpp" open="1" top="1" tabpos="7" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="496" topLine="7" />
<Cursor1 position="4323" 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="main.cpp" 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="2853" 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="my_data.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2862" topLine="116" />
<Cursor1 position="121" topLine="0" />
</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.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1006" topLine="0" />
<Cursor1 position="822" 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="my_data.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="774" topLine="0" />
<Cursor1 position="101" topLine="0" />
</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="operation.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="688" topLine="17" />
<Cursor1 position="1835" topLine="0" />
</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="operation.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="207" topLine="0" />
</Cursor>
Expand Down
Binary file added bin/Debug/ASD_Task_3.exe
Binary file not shown.
98 changes: 71 additions & 27 deletions list.cpp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#include "list.h"
#include "my_data.h"

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 +19,13 @@ address allocate(infotype x) {

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


P=new elmlist;
P->info.ID=x.ID;
P->info.name=x.name;
P->info.rank=x.rank;
P->info.score=x.score;
P->next=NULL;
P->prev=NULL;
//----------------------------------------
return P;
}
Expand All @@ -31,8 +35,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){
L.first=P;
L.last=P;
}else {
P->next=L.first;
L.first->prev=P;
L.first=P;
}
//----------------------------------------
}

Expand All @@ -55,8 +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){
L.first=P;
L.last=P;
}else {
L.last->next=P;
P->prev=L.last;
L.last=P;
}

//----------------------------------------
}
Expand All @@ -70,9 +84,10 @@ address findElm(List L, infotype x) {

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


P=L.first;
while (P!=NULL && P->info.ID!=x.ID){
P=P->next;
}
//----------------------------------------
return P;
}
Expand All @@ -83,9 +98,16 @@ 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


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

//----------------------------------------
}
Expand All @@ -96,8 +118,16 @@ 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

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


//----------------------------------------
Expand All @@ -109,9 +139,13 @@ 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);
while (P != NULL)
{
cout<<P->info.ID<<" "<<P->info.name<<" "<<P->info.rank<<" "<<P->info.score<<endl;
P = next(P);
}
cout<<endl;
//----------------------------------------
}

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

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

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

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

//----------------------------------------
}
Expand Down
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
53 changes: 51 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ int main() {
void mainMenu() {
address P;
infotype X;
mytype member;
/**
* IS : List has been created
* PR : prints menu to user
Expand Down Expand Up @@ -50,8 +51,56 @@ void mainMenu() {
switch(choice) {
case 1:
X = create_data();
P = allocate(X);
insertFirst(L,P)
insertAndSort(L,X);
break;
case 2:
if (L.first!=NULL){
cout<<"Data Member :"<<endl;
printInfo(L);
}else {
cout<<"Tidak ada member"<<endl;
}
cout<<endl;
break;
case 3:
cout<<"Masukkan ID member yang ingin dicari :";
cin>>member.ID;
if (findElm(L,member)!=NULL){
view_data(findElm(L,member)->info);
}else {
cout<<"ID Member tidak ditemukan"<<endl;
}
cout<<endl;
break;
case 4:
cout<<"Masukkan ID member yang ingin diedit :";
cin>>member.ID;
if (findElm(L,member)!=NULL){
edit_data(findElm(L,member)->info);
}else {
cout<<"ID Member tidak ditemukan"<<endl;
}
cout<<endl;
break;
case 5:
cout<<"Masukkan ID member yang ingin dihapus :";
cin>>member.ID;
if (findElm(L,member)!=NULL){
deletebyID(L,member.ID);
cout<<"Data member telah dihapus";
}else {
cout<<"ID Member tidak ditemukan"<<endl;
}
cout<<endl;
break;
case 6:
savePassedMember(L,L_passed);
cout<<"Pemindahan data member yang Lulus berhasil..."<<endl;
break;
case 7:
cout<<"Data Mahasiswa yang telah Lulus:"<<endl;
printInfo(L_passed);
cout<<endl;
break;
}
} while(true);
Expand Down
Loading