forked from ASD-ADF/ASD_Task_4
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
101 lines (94 loc) · 2.55 KB
/
main.cpp
File metadata and controls
101 lines (94 loc) · 2.55 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
#include <iostream>
#include "doublelist.h"
#include "operation.h"
#include "my_data.h"
#include "my_data2.h"
using namespace std;
void mainMenu();
List L;
int main() {
createList(L);
mainMenu();
return 0;
}
void mainMenu() {
address P;
infotype X;
infotype2 Y;
/**
* IS : List has been created
* PR : prints menu to user
* 1. insert new data
* 2. print all data
* 3. find and print a data by ID
* 4. edit data by ID
* 5. delete data by ID
* 0. exit
*/
//-------------your code here-------------
int choice;
do {
cout<<"Menu"<<endl;
cout<<"1. insert"<<endl;
cout<<"2. view data"<<endl;
cout<<"3. find and view"<<endl;
cout<<"4. find and edit"<<endl;
cout<<"5. find and delete"<<endl;
cout<<"0. exit"<<endl;
cout<<"input choice: ";
cin>>choice;
switch(choice) {
case 1:
X = create_data(X);
Y = create_data(Y);
P = allocate(X,Y);
insertAndSort(L,P);
break;
case 2:{
printInfo(L);
break;
}
case 3: {
infotype i;
cout<<"Input ID : ";
cin>>i.id;
address in = findElm(L,i);
if(in != NULL){
cout<<"=STUDENT="<<endl;
cout<<"ID : ";cout<<in->info.id<<endl;
cout<<"Name : ";cout<<in->info.name<<endl;
cout<<"Class : ";cout<<in->info.clas<<endl;
cout<<"Score : ";cout<<in->info.score<<endl;
cout<<"=Lecturer="<<endl;
cout<<"ID : ";cout<<in->info2.id_lec<<endl;
cout<<"Name : ";cout<<in->info2.name_lec<<endl;
cout<<"Subject : ";cout<<in->info2.clas_lec<<endl;
cout<<"--------------"<<endl;
}else{
cout<<"ID is not FOUND"<<endl;
}
break;
}
case 4: {
infotype i;
cout << " Input ID : " ;
cin >> i.id;
address in = findElm(L,i);
if (in != NULL){
edit_data(info(in));
edit_data(info2(in));
} else {
cout << "ID not FOUND" << endl;
}
break;
}
case 5: {
infotype i;
cout << " ID not FOUND ";
cin >> i.id;
deletebyID(L,i);
}
}
} while(true);
//----------------------------------------
}