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
|
#include "Contact.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main(){
string fname;
string lname;
string address;
string phone;
string city;
string state;
Contact myContact1(fname, lname, phone, address, city, state);
Contact myContact2(fname, lname, phone);
char ch;
int op;
do{
cout<<"\t\tMake your choice "<<endl;
cout<<"\t-1- Add Contact"<<endl;
cout<<"\t-2- List Contact"<<endl;
cout<<"\t-3- Modify Contact"<<endl;
cout<<"\t-4- Find Contact"<<endl;
cout<<"\t-5- Quit"<<endl;
cout<<"\t\tChoice :> ";
cin>>op;
cin.ignore();
switch(op){
case 1: //Calling Adding function
cout<<"\t\t----- Add Contact -----"<<endl;
cout<<"First Name :> ";
getline(cin,fname);
cout<<"Last Name :> ";
getline(cin,lname);
cout<<"Phone # :> ";
getline(cin,phone);
cout<<"Address :> ";
getline(cin,address);
cout<<"city :> ";
getline(cin,city);
cout<<"state :> ";
getline(cin,state);
myContact1.setFirstName(fname);
myContact1.setLastName(lname);
myContact1.setPhone(phone);
myContact1.setAddress(address);
myContact1.setCity(city);
myContact1.setState(state);
break;
case 2: //calling listing function
cout<<"\t\t----- List Contact -----"<<endl;
cout<<myContact1.getFirstName()<<" "<<myContact1.getLastName()<<"\t"<<myContact1.getPhone()<<endl;
cout<<myContact1.getAddress()<<endl;
cout<<myContact1.getCity()<<", "<<myContact1.getState()<<endl;
break;
case 3: //calling modifying function
cout<<"\t\t----- Modify Contact -----"<<endl;
cout<<"New First Name:> ";
getline(cin,fname);
cout<<"New Last Name :> ";
getline(cin,lname);
cout<<"New Phone # :> ";
getline(cin,phone);
myContact2.setFirstName(fname);
myContact2.setLastName(lname);
myContact2.setPhone(phone);
break;
case 4: //calling finding function
break;
case 5: //quit the program
cout<<"\t\tQuit The programm!!!"<<endl;
exit(1);
default: //if the user tape the wrong letter
cout<<"\t\tWrong Choice !!!"<<endl;
break;
}
cout<<"\tWould you like to continue the program??? (Y/n) :> ";
cin>>ch;
}
while(ch=='y' || ch=='Y');
return 0;
}
|