Advertisement
DestinyHer0o

5

Oct 20th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.26 KB | None | 0 0
  1. Дом 5 – ООП-I част Кристиан Иванов Иванов, Ф№:18621357, КСТ 2ри курс 1-‚б‘ група
  2. Лекар трябва да подържа статистика за броя посещения на всички пациенти, лекара записва: Име на пациента, дата на раждане, и брой посещения на пациента. Програмата съдържа списък от пациенти, намира средния брой посещения на пациентите както и пациентите направили повече от зададен брой посещения.
  3.  
  4. #include <iostream>
  5. #include <string>
  6.  
  7. using namespace std;
  8. #define size 3
  9. class Patient
  10. {
  11. private:
  12. string namePatient;
  13. string dateOfBirthPatient;
  14. int numberOfVisitsPatient;
  15. public:
  16. Patient()
  17. {
  18. namePatient = "Nameless";
  19. dateOfBirthPatient = "XX.XX.XXXX";
  20. numberOfVisitsPatient = 0;
  21. }
  22. Patient(string getNamePatient, string getBirthDatePatient)
  23. {
  24. namePatient = getNamePatient;
  25. dateOfBirthPatient = getBirthDatePatient;
  26. numberOfVisitsPatient = 0;
  27. }
  28. void show()
  29. {
  30. cout << "Patient Name: " << namePatient << ", Birth Date: " << dateOfBirthPatient << ", Number of Visits: " << numberOfVisitsPatient << endl;
  31. }
  32.  
  33. int addNumOfVisits()
  34. { return(numberOfVisitsPatient++); }
  35.  
  36. friend int AvarageNumberOfVisits(Patient per[size]);
  37.  
  38. friend int FrequentlyVisitedPatient(Patient per[size], int n);
  39. };
  40.  
  41. int AvarageNumberOfVisits(Patient per[size])
  42. {
  43. int average = 0;
  44. for (int i = 0; i < size; i++)
  45. {
  46. average = average + per[i].numberOfVisitsPatient;
  47. }
  48. average = average / size;
  49. return average;
  50. }
  51.  
  52. int FrequentlyVisitedPatient(Patient per[size], int numOfVisits)
  53. {
  54. int counter = 0;
  55. for (int i = 0; i < size; i++)
  56. if (per[i].numberOfVisitsPatient > numOfVisits)
  57. {
  58. counter++;
  59. }
  60. return counter;
  61. }
  62.  
  63. void main()
  64. {
  65. unsigned int visitedNumber(0);
  66. Patient person[size];
  67. person[0] = Patient("Kristian Ivanov", "05.05.1999");
  68. person[1] = Patient("Martin Georgiev", "12.02.2005");
  69. person[2] = Patient("Ivan Petrov", "28.12.1985");
  70. person[0].addNumOfVisits();
  71. person[0].show();
  72. person[1].addNumOfVisits();
  73. person[1].show();
  74. person[2].addNumOfVisits();
  75. person[2].show();
  76. person[1].addNumOfVisits();
  77. person[1].show();
  78. person[2].addNumOfVisits();
  79. person[2].show();
  80. person[2].addNumOfVisits();
  81. person[2].show();
  82. cout<<"Avarage Number of Visits: "<< AvarageNumberOfVisits(person)<<endl;
  83. cout << "Search for a patient who has made more than a specified number of visits: ";
  84. cin >> visitedNumber;
  85. cout << "The number of patient made more than the specified number " << visitedNumber << " is: " << FrequentlyVisitedPatient(person, visitedNumber) << endl;
  86. system("pause");
  87. }
  88.  
  89.  
  90. //#include <iostream>
  91. //#include <string>
  92. //using namespace std;
  93. //
  94. //#define size 3
  95. //
  96. //class Pacient
  97. //{
  98. // string ime;
  99. // string data;
  100. // int CountVisits;
  101. //public:
  102. // Pacient() {};
  103. // Pacient(string x, string y, int z)
  104. // {
  105. // ime = x;
  106. // data = y;
  107. // CountVisits = z;
  108. // }
  109. // void show()
  110. // {
  111. // cout << ime << endl;
  112. // cout << data << endl;
  113. // cout << CountVisits << endl;
  114. // }
  115. // friend int AverageCountVisits(Pacient p[size]);
  116. // friend int MoreVisits(Pacient p[size], int n);
  117. //};
  118. //int AverageCountVisits(Pacient p[size])
  119. //{
  120. // int average = 0;
  121. // for (int i = 0; i < size; i++)
  122. // average = average + p[i].CountVisits;
  123. // average = average / size;
  124. // return average;
  125. //}
  126. //int MoreVisits(Pacient p[size], int n)
  127. //{
  128. // int count = 0;
  129. // for (int i = 0; i < size; i++)
  130. // if (p[i].CountVisits > n)
  131. // count++;
  132. // return count;
  133. //}
  134. //void main()
  135. //{
  136. // Pacient pac[size];
  137. // pac[0] = Pacient("Ivan", "12.11.1999", 15);
  138. // pac[1] = Pacient("Darin", "14.12.1994", 20);
  139. // pac[2] = Pacient("Krasimir", "16.10.1989", 18);
  140. // cout << "Sredniq broi na poseshteniq na pacientite e: " << AverageCountVisits(pac) << endl;
  141. // cout << "Vuvedete broi na poseshteniq chrez koito pacientite da se izvedat: " << endl;
  142. // unsigned int number(0);
  143. // cin >> number;
  144. // cout << "Broqt na pacientite napravili poveche ot zadaden broi poseshteniq " << number << " e:" << MoreVisits(pac, number) << endl;
  145. // system("pause");
  146. //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement