Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Дом 5 – ООП-I част Кристиан Иванов Иванов, Ф№:18621357, КСТ 2ри курс 1-‚б‘ група
- Лекар трябва да подържа статистика за броя посещения на всички пациенти, лекара записва: Име на пациента, дата на раждане, и брой посещения на пациента. Програмата съдържа списък от пациенти, намира средния брой посещения на пациентите както и пациентите направили повече от зададен брой посещения.
- #include <iostream>
- #include <string>
- using namespace std;
- #define size 3
- class Patient
- {
- private:
- string namePatient;
- string dateOfBirthPatient;
- int numberOfVisitsPatient;
- public:
- Patient()
- {
- namePatient = "Nameless";
- dateOfBirthPatient = "XX.XX.XXXX";
- numberOfVisitsPatient = 0;
- }
- Patient(string getNamePatient, string getBirthDatePatient)
- {
- namePatient = getNamePatient;
- dateOfBirthPatient = getBirthDatePatient;
- numberOfVisitsPatient = 0;
- }
- void show()
- {
- cout << "Patient Name: " << namePatient << ", Birth Date: " << dateOfBirthPatient << ", Number of Visits: " << numberOfVisitsPatient << endl;
- }
- int addNumOfVisits()
- { return(numberOfVisitsPatient++); }
- friend int AvarageNumberOfVisits(Patient per[size]);
- friend int FrequentlyVisitedPatient(Patient per[size], int n);
- };
- int AvarageNumberOfVisits(Patient per[size])
- {
- int average = 0;
- for (int i = 0; i < size; i++)
- {
- average = average + per[i].numberOfVisitsPatient;
- }
- average = average / size;
- return average;
- }
- int FrequentlyVisitedPatient(Patient per[size], int numOfVisits)
- {
- int counter = 0;
- for (int i = 0; i < size; i++)
- if (per[i].numberOfVisitsPatient > numOfVisits)
- {
- counter++;
- }
- return counter;
- }
- void main()
- {
- unsigned int visitedNumber(0);
- Patient person[size];
- person[0] = Patient("Kristian Ivanov", "05.05.1999");
- person[1] = Patient("Martin Georgiev", "12.02.2005");
- person[2] = Patient("Ivan Petrov", "28.12.1985");
- person[0].addNumOfVisits();
- person[0].show();
- person[1].addNumOfVisits();
- person[1].show();
- person[2].addNumOfVisits();
- person[2].show();
- person[1].addNumOfVisits();
- person[1].show();
- person[2].addNumOfVisits();
- person[2].show();
- person[2].addNumOfVisits();
- person[2].show();
- cout<<"Avarage Number of Visits: "<< AvarageNumberOfVisits(person)<<endl;
- cout << "Search for a patient who has made more than a specified number of visits: ";
- cin >> visitedNumber;
- cout << "The number of patient made more than the specified number " << visitedNumber << " is: " << FrequentlyVisitedPatient(person, visitedNumber) << endl;
- system("pause");
- }
- //#include <iostream>
- //#include <string>
- //using namespace std;
- //
- //#define size 3
- //
- //class Pacient
- //{
- // string ime;
- // string data;
- // int CountVisits;
- //public:
- // Pacient() {};
- // Pacient(string x, string y, int z)
- // {
- // ime = x;
- // data = y;
- // CountVisits = z;
- // }
- // void show()
- // {
- // cout << ime << endl;
- // cout << data << endl;
- // cout << CountVisits << endl;
- // }
- // friend int AverageCountVisits(Pacient p[size]);
- // friend int MoreVisits(Pacient p[size], int n);
- //};
- //int AverageCountVisits(Pacient p[size])
- //{
- // int average = 0;
- // for (int i = 0; i < size; i++)
- // average = average + p[i].CountVisits;
- // average = average / size;
- // return average;
- //}
- //int MoreVisits(Pacient p[size], int n)
- //{
- // int count = 0;
- // for (int i = 0; i < size; i++)
- // if (p[i].CountVisits > n)
- // count++;
- // return count;
- //}
- //void main()
- //{
- // Pacient pac[size];
- // pac[0] = Pacient("Ivan", "12.11.1999", 15);
- // pac[1] = Pacient("Darin", "14.12.1994", 20);
- // pac[2] = Pacient("Krasimir", "16.10.1989", 18);
- // cout << "Sredniq broi na poseshteniq na pacientite e: " << AverageCountVisits(pac) << endl;
- // cout << "Vuvedete broi na poseshteniq chrez koito pacientite da se izvedat: " << endl;
- // unsigned int number(0);
- // cin >> number;
- // cout << "Broqt na pacientite napravili poveche ot zadaden broi poseshteniq " << number << " e:" << MoreVisits(pac, number) << endl;
- // system("pause");
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement