-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.cpp
152 lines (127 loc) · 4.26 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include<iostream>
#include"Address.h"
#include"Contact.h"
#include"ContactsBook.h"
Address* address() {
Address* add = new Address;
std::cin >> *add;
return add;
}
int main() {
int choice = 0;
std::string search;
std::string fname ="fn", lname ="ln", email= "email", mobile = "mobile";
Contact contact;
ContactsBook book;
Address *add = new Address[10];
do
{
std::cout << "----------Contact Book-----------\n";
std::cout << "1-Create Contact List(from given size)\n2-Add New Contact\n";
std::cout << "3-Merge Duplicates\n4-Store to File\n5-Load from File\n6-Print Contacts Sorted\n";
std::cout << "7-Print Contacts\n8-Search Contacts\n9-Display Count of Contacts\n";
std::cout << "0-Exit\nEnter Your Choice: ";
std::cin >> choice;
switch (choice) {
case 1:
int size;
std::cout << "Enter size of Contact Book: ";
std::cin >> size;
std::cout << "Contact Book Created\n";
book.setsize(size);
break;
case 2:
std::cin >> contact;
std::cin >> *add;
contact.setAddress(*add);
book.add_contact(contact);
break;
case 3:
book.merge_duplicates();
break;
case 4:
book.save_to_file("Load_from_file.txt");
break;
case 5:
book.load_from_file("Load_from_file.txt");
break;
case 6:
book.print_contacts_sorted("first name");
break;
case 7:
book.print_contacts_unsorted();
break;
case 8:
std::cout << "Search Contact: ";
std::cin >> search;
book.search_contact(search);
break;
case 9:
std::cout<<"Total Contacts: "<<book.total_contacts() << std::endl;
break;
}
system("pause");
system("cls");
} while (choice != 0);
//scenerio-1
/*ContactsBook Book(5);
Contact *contact = new Contact[5];
Address* add = new Address[5];
Address add1("1", "H Block", "Lahore", "Pakistan");
Address add2("2", "k Block", "Lahore", "Pakistan");
Address add3("3", "F Block", "Lahore", "Pakistan");
Address add4("4", "A Block", "Lahore", "Pakistan");
Address add5("5", "Z Block", "Lahore", "Pakistan");
Contact contact1("Ahmad", "Raath", "03014111624", "[email protected]", &add1);
Contact contact2("Talib", "Husain", "03014111624", "[email protected]", &add2);
Contact contact3("Zohaan", "Khadim", "03014111624", "[email protected]", &add3);
Contact contact4("Noor", "Ahmad", "03014111624", "[email protected]", &add3);
Contact contact5("Usaman", "Ali", "03014111624", "[email protected]", &add3);
Book.add_contact(contact2);
Book.add_contact(contact1);
Book.add_contact(contact3);
Book.add_contact(contact4);
Book.add_contact(contact5);
/*cout << "ENter the Data\n";
for (int i = 0; i < 2; i++) {
cin >> contact[i];
cin >> add[i];
contact[i].setAddress(add[i]);
Book.add_contact(contact[i]);
}
cout << "Unsorted Contacts\n";
Book.print_contacts_unsorted();
cout << "Sorted Contacts\n";
Book.print_contacts_sorted("first name");
//scenerio-2
cout<<"Total Counts = "<<Book.total_contacts()<<endl;
Address add6("6", "k Block", "Lahore", "Pakistan");
Address add7("7", "X Block", "Lahore", "Pakistan");
Contact contact6("ALi", "Raath", "03014111624", "[email protected]", &add6);
Contact contact7("sana", "Husain", "03014111624", "[email protected]", &add7);
Book.add_contact(contact6);
Book.add_contact(contact7);
cout << "Total Contacts After adding 2 moer: " << Book.total_contacts() << endl;
*/
//Scenero-3
//ContactsBook book(5);
//Address add1("365", "F Block", "Lahore", "Pakistan");
//Address add2("895", "H Block", "Lahore", "Pakistan");
//Address add3("120/1", "J Block", "Lahore", "Pakistan");
//Address add4("164", "K Block", "Lahore", "Pakistan");
//Contact contact1("Talib", "Raath", "03217330477" ,"[email protected]", &add1);
//Contact contact2("Fida", "Raath", "03014111624", "[email protected]", &add2);
//Contact contact3("Muhammad", "Aslam", "03015468953", "[email protected]", &add3);
//Contact contact4("Khadim", "Husain", "03004801494", "[email protected]", &add4);
//Contact contact5("Khadim", "Husain", "03004801494", "[email protected]", &add4);
//book.add_contact(contact1);
//book.add_contact(contact2);
//book.add_contact(contact3);
//book.add_contact(contact4);
//book.add_contact(contact5);
//book.merge_duplicates();
//Scenerio-4
//book.load_from_file("Load_from_file.txt");
//book.print_contacts_sorted("first name");
//book.save_to_file("Load_from_file.txt");
}