forked from ASD-ADF/ASD_Task_3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
135 lines (127 loc) · 3.19 KB
/
Copy pathmain.cpp
File metadata and controls
135 lines (127 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#include <iostream>
#include "list.h"
#include "operation.h"
#include "my_data.h"
using namespace std;
void mainMenu();
List L, L_passed;
int main() {
createList(L);
createList(L_passed);
mainMenu();
return 0;
}
void mainMenu() {
address P;
infotype x;
/**
* IS : List has been created
* PR : prints menu to user
* 1. insert new data
* 2. print all data (List L)
* 3. find and print a data by ID
* 4. edit data by ID
* 5. delete data by ID
* 6. separate passed member
* 7. print all data (List L2)
* 0. exit
*/
//-------------your code here-------------
int choice;
do {
cout<<"Menu"<<endl;
cout<<"1. insert"<<endl;
cout<<"2. view member"<<endl;
cout<<"3. find and view"<<endl;
cout<<"4. find and edit"<<endl;
cout<<"5. find and delete"<<endl;
cout<<"6. separate passed member"<<endl;
cout<<"7. view passed member"<<endl;
cout<<"0. exit"<<endl;
cout<<"input choice: ";
cin>>choice;
switch(choice) {
case 1:
{
x = create_data();
P = allocate(x);
insertFirst(L,P);
break;
}
case 2 :
{
printInfo(L);
break;
}
case 3 :
{
cout<<"ID yang dicari :";
cin>> x.ID;
address temu ;
temu = findElm(L,x);
if ( temu != NULL)
{
view_data(info(P));
}
else
{
cout<<"Maaf data tidak ditemukan"<<endl;
}
break;
}
case 4 :
{
cout<<"ID yang akan diedit :";
cin>> x.ID;
address ubah;
ubah = findElm(L,x);
if ( ubah != NULL)
{
edit_data(info(P));
}
else
{
cout<<"Maaf ID anda tidak dapat diedit."<<endl;
}
break;
}
case 5 :
{
infotype a;
address cari;
cari = findElm(L, a);
cout<"Mencari ID : ";
cin>>a.ID;
if ( cari == first(L))
{
deleteFirst(L,cari);
}
else if ( cari == last(L))
{
deleteLast(L, cari);
}
else
{
deleteAfter(L, prev(cari), cari);
}
cout<<"Penghapusan Berhasil";
break;
}
case 6 :
{
savePassedMember(L,L_passed);
break;
}
case 7 :
{
printInfo(L_passed);
break;
}
}
if (choice == 0)
{
break;
}
} while(true);
//----------------------------------------
}