-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
75 lines (63 loc) · 2.17 KB
/
main.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
#include <iostream>
#include <iomanip>
#include <limits>
#include <string>
#include "Helper.h"
#include "ArrayFileManager.h"
#include "DisplayController.h"
using namespace std;
int CONTACT_COUNTER = 0;
int main()
{
const int NUM_CONTACTS = 100;
Contact contacts[NUM_CONTACTS];
ArrayFileManager::loadArrayFromFile(contacts, CONTACT_COUNTER, "contacts.txt");
while (true)
{
system("cls");
cout << "............................................\n";
cout << " Contact Manager \n";
cout << "............................................\n\n";
cout << "::::::::::::::: PROGRAM MENU :::::::::::::::\n";
cout << "1. Save New Contact\n";
cout << "2. Display All Saved Contacts\n";
cout << "3. Search Specific Contact\n";
cout << "4. Modify Existing Contact\n";
cout << "5. Delete Specific Contact\n";
cout << "6. Delete All Existing Contacts\n";
cout << "0. Exit\n\n";
cout << "Enter Your Choice : ";
int menuInpute = Helper::getRangeInput(0, 6);
switch (menuInpute)
{
case 1:
DisplayController::addContact(&contacts[CONTACT_COUNTER], contacts, &CONTACT_COUNTER);
cout << CONTACT_COUNTER << endl;
break;
case 2:
DisplayController::listContact(contacts, CONTACT_COUNTER);
break;
case 3:
DisplayController::searchByName(contacts, CONTACT_COUNTER);
break;
case 4:
DisplayController::updateContact(contacts, CONTACT_COUNTER);
break;
case 5:
DisplayController::deleteContact(contacts, &CONTACT_COUNTER);
break;
case 6:
DisplayController::deleteData(contacts, &CONTACT_COUNTER);
break;
case 0:
cout << "Have a nice day!" << endl;
ArrayFileManager::saveArrayToFile(contacts, CONTACT_COUNTER, "contacts.txt");
exit(0);
default:
cout << "Invalid Option!!" << endl;
break;
}
}
ArrayFileManager::saveArrayToFile(contacts, CONTACT_COUNTER, "contacts.txt");
return 0;
}