daily pastebin goal
22%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<map>
  3. #include<string>
  4. #include<vector>
  5.  
  6. using namespace std;
  7.  
  8. class DateOfBirth
  9. {
  10.     int d,m,y;
  11. public:
  12.     DateOfBirth(int d = 0,int m = 0,int y = 0)
  13.     {
  14.         this -> d = d;
  15.         this -> m = m;
  16.         this -> y = y;
  17.     }
  18.  
  19.     int GetDay ()
  20.     {
  21.         return d;
  22.     }
  23.  
  24.     int GetMonth ()
  25.     {
  26.         return m;
  27.     }
  28.  
  29.     int GetYear ()
  30.     {
  31.         return y;
  32.     }
  33.  
  34.     void print()
  35.     {
  36.         cout << d << "/" << m << "/" << y << endl;
  37.     }
  38. };
  39.  
  40. class Patient
  41. {
  42.     string name;
  43.     int  visits;
  44.     DateOfBirth date;
  45. public:
  46.     Patient(string name ,int visits,DateOfBirth date)
  47.     {
  48.         this -> name = name;
  49.         this -> visits = visits;
  50.         this -> date = date;
  51.     }
  52.  
  53.     DateOfBirth GetDate()
  54.     {
  55.         return this -> date;
  56.     }
  57.  
  58.     string GetName ()
  59.     {
  60.         return name;
  61.     }
  62.  
  63.     int GetVisits ()
  64.     {
  65.         return visits;
  66.     }
  67.  
  68.     void PrintAll ()
  69.     {
  70.         cout << "Name: " << name << endl;
  71.         cout << "Visitrs: " << visits << endl;
  72.         cout << "Birthday: ";
  73.         date.print();
  74.         cout << endl;
  75.     }
  76.  
  77. };
  78.  
  79. int main()
  80. {
  81.     cout << "Enter number of patients : ";
  82.     int numOfPatients = 0;
  83.     cin >> numOfPatients;
  84.  
  85.     vector<Patient>patients;
  86.  
  87.     for(int i = 0; i < numOfPatients; ++i)
  88.     {
  89.         int d,m,y,visits;
  90.         string name;
  91.  
  92.         cout << "Enter name : " << endl;
  93.         cin >> name;
  94.  
  95.         cout << "Enter date of birthday (dd/mm/year) : "<< endl;
  96.         cout << "Enter date: "<< endl;
  97.         cin >> d;
  98.  
  99.         cout << "Enter month: "<< endl;
  100.         cin >> m;
  101.  
  102.         cout << "Enter year: "<< endl;
  103.         cin >> y;
  104.         DateOfBirth tempDate(d,m,y);
  105.  
  106.         cout << "Enter number of visits: "<< endl;
  107.         cin >> visits;
  108.  
  109.         Patient temp(name,visits,tempDate);
  110.         patients.push_back(temp);
  111.     }
  112.  
  113.         for (int i = 0; i < numOfPatients; ++ i )
  114.         {
  115.         patients[i].PrintAll();
  116.         }
  117.  
  118.  
  119.  
  120.     return 0;
  121. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top