Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2018
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.03 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. class Address{
  6. public:
  7. string street;
  8. int number;
  9. int t_k;
  10. string town;
  11. string country;
  12.  
  13. Address();
  14. Address(string newStreet, int newNumber, int newT_k, string newTown, string newCountry);
  15. ~Address();
  16. void display();
  17. };
  18.  
  19. Address::Address(){
  20. street="street";
  21. number=144;
  22. t_k=18544;
  23. town="town";
  24. country="country";
  25. }
  26.  
  27. Address::Address(string newStreet, int newNumber, int newT_k, string newTown, string newCountry){
  28. street=newStreet;
  29. number=newNumber;
  30. t_k=newT_k;
  31. town=newTown;
  32. country=newCountry;
  33. }
  34.  
  35. Address::~Address(){
  36. cout<<"Address constructor"<<endl;
  37. }
  38.  
  39. void Address::display(){
  40. cout<<"Street: "<<street<<"\nNumber: "<<number<<"\nT_k: "<<t_k<<"\nTown: "<<town<<"\nCountry: "<<country<<endl;
  41. }
  42.  
  43. class Patient{
  44. public:
  45. string name;
  46. int yearOfBirth;
  47. Address address;
  48. string clinic;
  49. int room;
  50.  
  51. Patient();
  52. Patient(string newName, int newYearOfBirth, string newClinic, int newRoom);
  53. ~Patient();
  54. void display();
  55. };
  56.  
  57. Patient::Patient(){
  58. name="onoma";
  59. yearOfBirth=1999;
  60. Address A1();
  61. clinic="klinikh";
  62. room=120;
  63. }
  64.  
  65. Patient::Patient(string newName, int newYearOfBirth, string newClinic, int newRoom){
  66. name=newName;
  67. yearOfBirth=newYearOfBirth;
  68. string str;
  69. int num;
  70. int tk;
  71. string town;
  72. string country;
  73. cout<<"give me your address(street, number of your house, tk, town, country)"<<endl;
  74. cin>>str;
  75. cin>>num;
  76. cin>>tk;
  77. cin>>town;
  78. cin>>country;
  79. Address A1(str, num, tk, town, country);
  80. clinic=newClinic;
  81. room=newRoom;
  82. }
  83.  
  84. Patient::~Patient(){
  85. cout<<"Patient destructor"<<endl;
  86. }
  87.  
  88.  
  89.  
  90. void Patient::display(){
  91. cout<<"--Name: "<<name<<endl;
  92. cout<<"--Year of birth: "<<yearOfBirth<<endl;
  93. cout<<"--Address: "<<endl;
  94. address.display();
  95. cout<<"--Clinic: "<<clinic<<endl;
  96. cout<<"--Room: "<<room<<endl;
  97.  
  98. }
  99.  
  100. int main()
  101. {
  102. Patient P1[10];
  103. int i=0, j, ans;
  104.  
  105. do{
  106. char answ;
  107.  
  108. Patient P1[i];
  109. string name;
  110. int year;
  111. string address;
  112. string clinic;
  113. int room;
  114.  
  115. cout<<"Give me your name."<<endl;
  116. cin>>name;
  117.  
  118. cout<<"When were you born?"<<endl;
  119. cin>>year;
  120.  
  121. cout<<"In which clinic are you in?"<<endl;
  122. cin>>clinic;
  123.  
  124. cout<<"In which room are you in?"<<endl;
  125. cin>>room;
  126.  
  127. i++;
  128.  
  129. cout<<"Do you wish to continue? [y/n]"<<endl;
  130. cin>>answ;
  131.  
  132. if (answ=='y'){
  133. ans=1;
  134. }else{
  135. ans=0;
  136. }
  137.  
  138. }while(!ans && i<=10);
  139.  
  140. for(j=0; j<=i; j++){
  141. display.P1[j]();
  142. };
  143.  
  144.  
  145. system("pause");
  146. return 0;
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement