silentkiler029

Question-04-a, b, c, d

Nov 1st, 2021 (edited)
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.51 KB | None | 0 0
  1. // Question - 04
  2.  
  3. #include <bits/stdc++.h>
  4. using namespace std;
  5.  
  6. // ---( a )---
  7. class person {
  8. private:
  9.     string firstName;
  10.     string lastName;
  11.  
  12. public:
  13.     person( string s1, string s2 ) {
  14.         firstName = s1;
  15.         lastName = s2;
  16.     }
  17.  
  18.     void print() {
  19.         // what to print?
  20.         std::cout << firstName << ' ' << lastName << endl;
  21.     }
  22.     void setName( string s1, string s2 ) {
  23.         firstName = s1;
  24.         lastName = s2;
  25.     }
  26.     string getFirstName() {
  27.         return firstName;
  28.     }
  29.     string gerLastName() {
  30.         return lastName;
  31.     }
  32. };
  33.  
  34. // ---( b )---
  35. class doctor : public person {
  36. private:
  37.     string doctorsSpeciality;
  38.  
  39. public:
  40.     doctor( string s1, string s2, string s3 ) : person( s1, s2 ) {
  41.         doctorsSpeciality = s3;
  42.     }
  43.     void setDoctorsSpeciality( string s ) {
  44.         doctorsSpeciality = s;
  45.     }
  46.     void getDoctorsSpeciality() {
  47.         return doctorsSpeciality;
  48.     }
  49. };
  50.  
  51. // ---( c )---
  52. class bill {
  53. private:
  54.     int patientId;
  55.     int pharmacyCharges;
  56.     int doctorsFee;
  57.     int roomCharges;
  58.  
  59. public:
  60.     bill( int id, int phc, int df, int rc ) {
  61.         patientId = id;
  62.         pharmacyCharges = phc;
  63.         doctorsFee = df;
  64.         roomCharges = rc;
  65.     }
  66.     void setPatientId( int id ) {
  67.         patientId = id;
  68.     }
  69.     void setPharmacyCharges( int charge ) {
  70.         pharmacyCharges = charge;
  71.     }
  72.     void setDoctorsFee( int fee ) {
  73.         doctorsFee = fee;
  74.     }
  75.     void setRoomCharges( int charge ) {
  76.         roomCharges = charge;
  77.     }
  78.     int getPatientId() {
  79.         return patientId;
  80.     }
  81.     int getPharmacyCharges() {
  82.         return pharmacyCharges;
  83.     }
  84.     int getDoctorsFee() {
  85.         return doctorsFee;
  86.     }
  87.     int getRoomCharges() {
  88.         return roomCharges;
  89.     }
  90. };
  91.  
  92. // ---( d )---
  93. class patient : public person {
  94. private:
  95.     int patientId;
  96.     int age;
  97.  
  98. public:
  99.     class date {
  100.         int day;
  101.         int month;
  102.         int year;
  103.         dateOfBirth( int dd, int mm, int yyyy ) {
  104.             day = dd;
  105.             month = mm;
  106.             year = yyyy;
  107.         }
  108.         void setDay( int d ) {
  109.             day = d;
  110.         }
  111.         void setMonth( int m ) {
  112.             month = m;
  113.         }
  114.         void setYear( int y ) {
  115.             year = y;
  116.         }
  117.         int getDay() {
  118.             return day;
  119.         }
  120.         int getMonth() {
  121.             return month;
  122.         }
  123.         int getYear() {
  124.             return year;
  125.         }
  126.     };
  127.     class doctor {
  128.         string physiciansName;
  129.  
  130.         doctor( stirng s ) {
  131.             physiciansName = s;
  132.         }
  133.         void setPhysiciansName( string s ) {
  134.             physiciansName = s;
  135.         }
  136.         string getPhysiciansName() {
  137.             return physiciansName;
  138.         }
  139.     };
  140.  
  141. private:
  142.     doctor doc;
  143.     date dateOfBirth;
  144.     date admitDate;
  145.     date dischargeDate;
  146.  
  147. public:
  148.     patient( string s1, string s2, int id, int a ) : person( s1, s2 ) {
  149.         patientId = id;
  150.         age = a;
  151.     }
  152.  
  153.     int getPatientId () {
  154.         return patientId;
  155.     }
  156.     int getAge() {
  157.         return age;
  158.     }
  159.     string getPhysiciansName() {
  160.         return doc.getPhysiciansName();
  161.     }
  162.     string getDateOfBirth() {
  163.         string dob = to_string( dateOfBirth.getDay() ) + "-" + to_string( dateOfBirth.getMonth() ) + "-" + to_string( dateOfBirth.getYear() );
  164.         return dob;
  165.     }
  166.     string getAdmitDate() {
  167.         string ad = to_string( admitDate.getDay() ) + "-" + to_string( admitDate.getMonth() ) + "-" + to_string( admitDate.getYear() );
  168.         return ad;
  169.     }
  170.     string getDischargeDate() {
  171.         string dd = to_string( dischargeDate.getDay() ) + "-" + to_string( dischargeDate.getMonth() ) + "-" + to_string( dischargeDate.getYear() );
  172.         return dd;
  173.     }
  174.  
  175.     void setPhysiciansName( stirng s ) {
  176.         doc = new doctor( s );
  177.     }
  178.     void setDateOfBirth ( int d, int m, int y ) {
  179.         dateOfBirth = new date( d, m, y );
  180.     }
  181.     void setAdmitDate ( int d, int m, int y ) {
  182.         admitDate = new date( d, m, y );
  183.     }
  184.     void setDischargeDate ( int d, int m, int y ) {
  185.         dischargeDate = new date( d, m, y );
  186.     }
  187. };
Add Comment
Please, Sign In to add comment