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

PR FROM MAYANG SARI_1301194227_IF-43-05 #175

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"

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

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

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

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

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

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

1582383117 source:c:\users\asus\documents\github\asd_task_3\list.cpp
"list.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="list.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="496" topLine="7" />
<Cursor1 position="1199" topLine="44" />
</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.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="288" topLine="0" />
<Cursor1 position="115" 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.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2862" topLine="116" />
<Cursor1 position="207" 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="my_data.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="572" 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="main.cpp" 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="1533" topLine="39" />
</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="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="688" topLine="17" />
<Cursor1 position="773" topLine="12" />
</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="list.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="207" topLine="0" />
<Cursor1 position="200" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>
Binary file added bin/Debug/ASD_Task_3.exe
Binary file not shown.
81 changes: 61 additions & 20 deletions list.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ void createList(List &L) {
* FS : set first(L) and last(L) with Null
*/
//-------------your code here-------------
your code here
first(L)=NULL;
last(L)=NULL;


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

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


//----------------------------------------
P = new elmlist;
info(P)=x;
next(P)=NULL;
return P;
//----------------------------------------

}

void deallocate(address &P) {
/**
* FS : delete element pointed by P
*/
//-------------your code here-------------
your code here
delete P;


//----------------------------------------
Expand All @@ -43,7 +45,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 (first(L)==NULL && last(L)==NULL){
first(L)=P;
last(L)=P;
}else{
next(P)=first(L);
prev(first(L))=P;
first(L)=P;
}


//----------------------------------------
Expand All @@ -55,7 +64,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 (first(L)==NULL && last(L)==NULL){
first(L)=P;
last(L)=P;
}else{
prev(P)=last(L);
next(last(L))=P;
last(L)=P;
}


//----------------------------------------
Expand All @@ -68,12 +84,10 @@ address findElm(List L, infotype x) {
return Null if such ID is not found
*/

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


//----------------------------------------
address P=first(L);
while (P!=NULL && info(P).ID!=x.ID){
P=next(P);
}
return P;
}

Expand All @@ -83,7 +97,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=first(L);
if (first(L)==last(L)){
first(L)=NULL;
last(L)=NULL;
}else {
first(L)=next(P);
next(P)=NULL;
prev(P)=NULL;
}



Expand All @@ -96,7 +118,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=last(L);
if (first(L)==last(L)){
first(L)=NULL;
last(L)=NULL;
}else {
last(L)=prev(P);
prev(P)=NULL;
next(P)=NULL;
}



Expand All @@ -109,8 +139,12 @@ 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){
view_data(info(P));
P=next(P);
}
cout<<endl;

//----------------------------------------
}
Expand All @@ -123,7 +157,10 @@ void insertAfter(List &L, address Prec, address P) {
* pointed by pointer Prec
*/
//-------------your code here-------------
your code here
next(P)=next(Prec);
prev(P)=Prec;
prev(next(Prec))=P;
next(Prec)=P;

//----------------------------------------

Expand All @@ -135,7 +172,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;


//----------------------------------------
Expand Down
18 changes: 8 additions & 10 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 @@ -36,16 +36,14 @@ typedef mytype infotype;
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
45 changes: 44 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,50 @@ void mainMenu() {
case 1:
X = create_data();
P = allocate(X);
insertFirst(L,P)
insertFirst(L,P);
break;
case 2:
printInfo(L);
cout<<endl;
break;
case 3:
cout<<"Masukkan ID yang dicari: ";
cin>>X.ID;
P=findElm(L, X);
if (P!=NULL){
view_data(info(P));
}else{
cout<<"Data Not Found";
}
break;
case 4:
cout<<"Masukkan ID yang akan diedit: ";
cin>>X.ID;
P=findElm(L, X);
if (P!=NULL){
edit_data(info(P));
}else{
cout<<"Data tidak ada"<<endl;
}
break;
case 5:
cout<<"Masukkan ID yang akan dihapus: ";
cin>>X.ID;
P=findElm(L, X);
if (P!=NULL){
deletebyID(L, X.ID);
cout<<"Data telah dihapus"<<endl;
}else{
cout<<"Data tidak ada"<<endl;
}
break;
case 6:
savePassedMember(L, L_passed);
cout<<"Data sudah dipisah"<<endl;
break;
case 7:
cout<<"Hasil: \n\n";
printInfo(L_passed);
break;
}
} while(true);
Expand Down
38 changes: 25 additions & 13 deletions my_data.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

#include "my_data.h"

/**
CLASS :
NAME :
STUDENT ID :
CLASS : IF-43-05
NAME : MAYANG SARI
STUDENT ID : 1301194227
**/

mytype create_data() {
Expand All @@ -15,8 +15,15 @@ mytype create_data() {
mytype d;
// ===========================
// YOUR CODE HERE
your code here

cout<<"Masukkan ID: ";
cin>>d.ID;
cout<<"Masukkan Nama: ";
cin>>d.name;
cout<<"Masukkan Rank: ";
cin>>d.Rank;
cout<<"Masukkan Score: ";
cin>>d.score;
cout<<endl;



Expand All @@ -32,11 +39,11 @@ void view_data(mytype d) {

// ===========================
// YOUR CODE HERE
your code here




cout<<"ID: "<<d.ID<<endl;
cout<<"Nama: "<<d.name<<endl;
cout<<"Ranking: "<<d.Rank<<endl;
cout<<"Score: "<<d.score<<endl;
cout<<endl;
// ===========================
}

Expand All @@ -50,8 +57,13 @@ void edit_data(mytype &d) {

// ===========================
// YOUR CODE HERE
your code here

cout<<"Masukkan nama baru: ";
cin>>d.name;
cout<<"Masukkan ranking baru: ";
cin>>d.Rank;
cout<<"Masukkan score baru: ";
cin>>d.score;
cout<<endl;



Expand Down
Loading