-
Notifications
You must be signed in to change notification settings - Fork 0
/
mainProgram.cpp
84 lines (74 loc) · 1.78 KB
/
mainProgram.cpp
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
/*
-----------------------------------
FINAL PROJECT STRUKTUR DATA TC 2021
-----------------------------------
Dibuat oleh:
Nama : Putu Ravindra Wiguna
NRP : 5025201237
Kelas : Struktur Data C
Tanggal Pembuatan pertama:
29 Juni 2021
*/
#include "utilities.hpp"
using namespace std;
int main(){
fstream textfile;
textfile.open("telepon.txt");
AVL nameTree, numberTree;
initializeAVL(&nameTree);
initializeAVL(&numberTree);
//extract data
if(textfile.is_open()){
contact person;
string tmp;
int counter = -1;
while( getline(textfile, tmp)){
counter++;
if(counter%2 == 0){
person.name = tmp;
}else{
person.number = tmp;
avlInsert(&nameTree, person, NAME);
avlInsert(&numberTree, person, NUMBER);
}
}
textfile.close();
}
else{
Log("Tidak dapat menemukan file telepon.txt!");
return 0;
}
//UI Start
welcomeMsg();
//program start
int command;
bool Running = true;
while(Running){
showMenu();
command = getCommand();
switch (command){
case 1:
LihatKontak(&nameTree, &numberTree);
break;
case 2:
TambahKontak(&nameTree, &numberTree);
break;
case 3:
HapusKontak(&nameTree, &numberTree);
break;
case 4:
SuntingKontak(&nameTree, &numberTree);
break;
case 5:
Running = false;
Log("Mengakhiri program");
break;
default:
//seharusnya tidak terjadi
Log("Terjadi suatu kesalahan");
break;
}
system("cls");
}
return 0;
}