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
|
#include <iostream>
#include <string>
using namespace std;
class phoneBook
{
private:
string n_phone;
string name_surname;
string Contatto;
int size = 10;
string* contact = new string[ size ];
public:
phoneBook( string, string, string ); //constructor
string t_n_phone = '\0'; //temporary var
string t_name_surname = '\0';
string t_contact = '\0';
string temp_n_phone();
string temp_name_surname();
string temp_contact();
int counter = 0;
bool value_temp_contact( string );
void registry_contact( string );
void printer();
} ;
inline phoneBook::phoneBook( string t_n_ph , string t_nm_srnm , string t_cntct )
{
n_phone = t_n_ph;
name_surname = t_nm_srnm;
size = counter;
Contatto = t_cntct;
}
inline string phoneBook::temp_n_phone()
{
string t_n_prefix_int;
string t_n_prefix_oper;
string t_number;
cout << " enter the new number, by entering: \n 1) country code -> enter; \n 2) prefix operator-> enter; \n 3) number-> enter " << endl;
getline( cin, t_n_prefix_int );
getline( cin, t_n_prefix_oper );
getline( cin, t_number );
return ( t_n_phone = t_n_prefix_int + " " + t_n_prefix_oper + " " + t_number );
}
inline string phoneBook::temp_name_surname()
{
string t_name;
string t_surname;
cout << " enter the name & surname, by entering: \n 1) name -> enter; \n 2) surname -> enter; \n " << endl;
getline( cin, t_name );
getline( cin, t_surname );
return ( t_name_surname = t_name + " " + t_surname );
}
inline string phoneBook::temp_contact()
{
return ( t_contact = temp_name_surname() + temp_n_phone() );
}
inline bool phoneBook::value_temp_contact( string t_cntct )
{
for (int i = 0; i < counter; i++)
{
if ( contact[i] == t_cntct )
{
cout << " this contact existing on phonebook " << endl;
return 0;
}
}
return 1;
}
inline void phoneBook::registry_contact( string t_cntct)
{
counter++;
contact[counter] = t_cntct;
cout << " the contact now is on phonebook " << endl;
}
inline void phoneBook::printer()
{
for (int i = 1; i <= counter; i++)
cout << contact[i] << endl;
}
int main()
{
class phoneBook c (c.t_n_phone,c.t_name_surname,c.t_contact);
char answer;
cout << " dou you want to additing new contact ? " << endl;
cin >> answer;
if (( answer == 'y') || ( answer == 'Y'))
{
while ( ( answer == 'y') || ( answer == 'Y'))
{
//c.phoneBook(c.t_n_phone,c.t_name_surname,c.t_contact);
c.temp_n_phone();
c.temp_name_surname();
c.temp_contact();
c.value_temp_contact(c.t_contact);
if ( c.value_temp_contact(c.t_contact) )
{
c.registry_contact(c.t_contact);
}
c.printer();
cout << " another additing? " << endl;
cin >> answer;
}
}
cout << "Hello world!" << endl;
return 0;
}
|