Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- class Address{
- public:
- string street;
- int number;
- int t_k;
- string town;
- string country;
- Address();
- Address(string newStreet, int newNumber, int newT_k, string newTown, string newCountry);
- ~Address();
- void display();
- };
- Address::Address(){
- street="street";
- number=144;
- t_k=18544;
- town="town";
- country="country";
- }
- Address::Address(string newStreet, int newNumber, int newT_k, string newTown, string newCountry){
- street=newStreet;
- number=newNumber;
- t_k=newT_k;
- town=newTown;
- country=newCountry;
- }
- Address::~Address(){
- cout<<"Address constructor"<<endl;
- }
- void Address::display(){
- cout<<"Street: "<<street<<"\nNumber: "<<number<<"\nT_k: "<<t_k<<"\nTown: "<<town<<"\nCountry: "<<country<<endl;
- }
- class Patient{
- public:
- string name;
- int yearOfBirth;
- Address address;
- string clinic;
- int room;
- Patient();
- Patient(string newName, int newYearOfBirth, string newClinic, int newRoom);
- ~Patient();
- void display();
- };
- Patient::Patient(){
- name="onoma";
- yearOfBirth=1999;
- Address A1();
- clinic="klinikh";
- room=120;
- }
- Patient::Patient(string newName, int newYearOfBirth, string newClinic, int newRoom){
- name=newName;
- yearOfBirth=newYearOfBirth;
- string str;
- int num;
- int tk;
- string town;
- string country;
- cout<<"give me your address(street, number of your house, tk, town, country)"<<endl;
- cin>>str;
- cin>>num;
- cin>>tk;
- cin>>town;
- cin>>country;
- Address A1(str, num, tk, town, country);
- clinic=newClinic;
- room=newRoom;
- }
- Patient::~Patient(){
- cout<<"Patient destructor"<<endl;
- }
- void Patient::display(){
- cout<<"--Name: "<<name<<endl;
- cout<<"--Year of birth: "<<yearOfBirth<<endl;
- cout<<"--Address: "<<endl;
- address.display();
- cout<<"--Clinic: "<<clinic<<endl;
- cout<<"--Room: "<<room<<endl;
- }
- int main()
- {
- Patient P1[10];
- int i=0, j, ans;
- do{
- char answ;
- Patient P1[i];
- string name;
- int year;
- string address;
- string clinic;
- int room;
- cout<<"Give me your name."<<endl;
- cin>>name;
- cout<<"When were you born?"<<endl;
- cin>>year;
- cout<<"In which clinic are you in?"<<endl;
- cin>>clinic;
- cout<<"In which room are you in?"<<endl;
- cin>>room;
- i++;
- cout<<"Do you wish to continue? [y/n]"<<endl;
- cin>>answ;
- if (answ=='y'){
- ans=1;
- }else{
- ans=0;
- }
- }while(!ans && i<=10);
- for(j=0; j<=i; j++){
- display.P1[j]();
- };
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement