Advertisement
JamesDamico

Backup

Apr 22nd, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 13.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <fstream>
  4.  
  5. using namespace std;
  6.  
  7. /////////////////////////////////////
  8. //// PersonalInfo
  9. ////////////////////////////////////
  10. class PersonalInfo {
  11. private:
  12.     string birthDate;
  13.     string gender;
  14. public:
  15.     PersonalInfo(string birth = "none", string gend = "none")
  16.     {
  17.         birthDate = birth;
  18.         gender = gend;
  19.     }
  20.  
  21.     void setBirthDate(string b)
  22.     {
  23.         birthDate = b;
  24.     }
  25.  
  26.     string getBirthDate()
  27.     {
  28.         return birthDate;
  29.     }
  30.  
  31.     void setGender(string g)
  32.     {
  33.         gender = g;
  34.     }
  35.  
  36.     string getGender()
  37.     {
  38.         return gender;
  39.     }
  40.  
  41.     void printPersonalInfo()
  42.     {
  43.         cout << "Birth Date: " << birthDate << endl;
  44.         cout << "Gender: " << gender << endl;
  45.     }
  46. };
  47.  
  48. /////////////////////////////////////
  49. //// ContactInfo
  50. ////////////////////////////////////
  51. class ContactInfo {
  52. private:
  53.     string phoneInfo;
  54.     string emailInfo;
  55. public:
  56.     ContactInfo(string phone = "none", string email = "none")
  57.     {
  58.         phoneInfo = phone;
  59.         emailInfo = email;
  60.     }
  61.  
  62.     void setPhoneInfo(string p)
  63.     {
  64.         phoneInfo = p;
  65.     }
  66.  
  67.     string getPhoneInfo()
  68.     {
  69.         return phoneInfo;
  70.     }
  71.  
  72.     void setEmailInfo(string e)
  73.     {
  74.         emailInfo = e;
  75.     }
  76.  
  77.     string getEmailInfo()
  78.     {
  79.         return emailInfo;
  80.     }
  81.  
  82.     void printContactInfo()
  83.     {
  84.         cout << "Phone Info: " << phoneInfo << endl;
  85.         cout << "Email Info: " << emailInfo << endl;
  86.     }
  87. };
  88.  
  89. /////////////////////////////////////
  90. //// HomeInfo
  91. ////////////////////////////////////
  92. class HomeInfo {
  93. private:
  94.     int streetNumber;
  95.     string street;
  96.     string city;
  97.     string state;
  98.     int zipCode;
  99.  
  100. public:
  101.     HomeInfo(int streetNum = 0, string str = "none", string cit = "none", string stat = "none", int zip = 0)
  102.     {
  103.         streetNumber = streetNum;
  104.         street = str;
  105.         city = cit;
  106.         state = stat;
  107.         zipCode = zip;
  108.     }
  109.  
  110.     void setStreetNumber(int s)
  111.     {
  112.         streetNumber = s;
  113.     }
  114.  
  115.     int getStreetNumber()
  116.     {
  117.         return streetNumber;
  118.     }
  119.  
  120.     void setStreet(string s)
  121.     {
  122.         street = s;
  123.     }
  124.  
  125.     string getStreet()
  126.     {
  127.         return street;
  128.     }
  129.  
  130.     void setCity(string c)
  131.     {
  132.         city = c;
  133.     }
  134.  
  135.     string getCity()
  136.     {
  137.         return city;
  138.     }
  139.  
  140.     void setState(string s)
  141.     {
  142.         state = s;
  143.     }
  144.  
  145.     string getState()
  146.     {
  147.         return state;
  148.     }
  149.  
  150.     void setZipCode(int z)
  151.     {
  152.         zipCode = z;
  153.     }
  154.  
  155.     int getZipCode()
  156.     {
  157.         return zipCode;
  158.     }
  159.  
  160.     void printHomeInfo()
  161.     {
  162.         cout << "Address: " << streetNumber << " " << street << ", " << city << ", " << state << " " << zipCode << endl;
  163.     }
  164. };
  165.  
  166. /////////////////////////////////////
  167. //// Person
  168. ////////////////////////////////////
  169. class Person {
  170. private:
  171.     string firstName;
  172.     string lastName;
  173.     PersonalInfo personal;
  174.     ContactInfo contact;
  175.     HomeInfo home;
  176.  
  177. public:
  178.  
  179.     Person(string first = "none", string last = "none", string birth = "none", string gend = "none", int streetNum = 0, string str = "none", string cit = "none", string stat = "none", int zip = 0, string phone = "none", string email = "none")
  180.         : personal(birth, gend),
  181.         contact(phone, email),
  182.         home(streetNum, str, cit, stat, zip)
  183.     {
  184.         firstName = first;
  185.         lastName = last;
  186.     }
  187.  
  188.     //No Home Info Constructor
  189.     Person(string first = "none", string last = "none", string birth = "none", string gend = "none", string phone = "none", string email = "none")
  190.         : personal(birth, gend),
  191.         contact(phone, email)
  192.     {
  193.         firstName = first;
  194.         lastName = last;
  195.     }
  196.  
  197.     void setFirstName(string f)
  198.     {
  199.         firstName = f;
  200.     }
  201.  
  202.     string getFirstName()
  203.     {
  204.         return firstName;
  205.     }
  206.  
  207.     void setLastName(string l)
  208.     {
  209.         lastName = l;
  210.     }
  211.  
  212.     string getLastName()
  213.     {
  214.         return lastName;
  215.     }
  216.  
  217.     void print()
  218.     {
  219.         cout << "First Name: " << firstName << endl;
  220.         cout << "Last Name: " << lastName << endl;
  221.         personal.printPersonalInfo();
  222.         contact.printContactInfo();
  223.         home.printHomeInfo();
  224.     }
  225.  
  226.     void printWithOutHome()
  227.     {
  228.         cout << "First Name: " << firstName << endl;
  229.         cout << "Last Name: " << lastName << endl;
  230.         personal.printPersonalInfo();
  231.         contact.printContactInfo();
  232.     }
  233. };
  234.  
  235. /////////////////////////////////////
  236. //// Patient
  237. ////////////////////////////////////
  238. class Patient : public Person
  239. {
  240. private:
  241.     int patientID;
  242.     int doctorID;
  243.  
  244.  
  245. public:
  246.  
  247.     Patient(string first = "none", string last = "none", int patient = 0, int doctor = 0, string birth = "none", string gend = "none", int streetNum = 0, string str = "none", string cit = "none", string stat = "none", int zip = 0, string phone = "none", string email = "none")
  248.         : Person(first, last, birth, gend, streetNum, str, cit, stat, zip, phone, email)
  249.     {
  250.         patientID = patient;
  251.         doctorID = doctor;
  252.     }
  253.  
  254.     void setDoctorID(int d)
  255.     {
  256.         doctorID = d;
  257.     }
  258.  
  259.     int getDoctorID()
  260.     {
  261.         return doctorID;
  262.     }
  263.  
  264.     void setPatientID(int p)
  265.     {
  266.         patientID = p;
  267.     }
  268.  
  269.     int getPatientID()
  270.     {
  271.         return patientID;
  272.     }
  273.  
  274.     void print()
  275.     {
  276.         cout << "Patient ID: " << patientID << endl;
  277.         cout << "Doctor ID: " << doctorID << endl;
  278.         Person::print();
  279.     }
  280. };
  281.  
  282.  
  283. /////////////////////////////////////
  284. //// Staff
  285. ////////////////////////////////////
  286. class Staff : public Person
  287. {
  288. private:
  289.     string staffType;
  290.     int staffID;
  291.     int departmentID;
  292. public:
  293.     Staff(string staffT = "none", string first = "none", string last = "none", int staffI = 0, int departmentI = 0, string birth = "none", string gend = "none", string phone = "none", string email = "none")
  294.         : Person(first, last, birth, gend, phone, email)
  295.     {
  296.         staffType = staffT;
  297.         staffID = staffI;
  298.         departmentID = departmentI;
  299.     }
  300.  
  301.     void setStaffType(string staffTy)
  302.     {
  303.         staffType = staffTy;
  304.     }
  305.  
  306.     string getStaffType()
  307.     {
  308.         return staffType;
  309.     }
  310.  
  311.     void setStaffID(int staffI)
  312.     {
  313.         staffID = staffI;
  314.     }
  315.  
  316.     int getStaffID()
  317.     {
  318.         return staffID;
  319.     }
  320.  
  321.     void setDepartmentID(int deptID)
  322.     {
  323.         departmentID = deptID;
  324.     }
  325.  
  326.     int getDepartmentID()
  327.     {
  328.         return departmentID;
  329.     }
  330.  
  331.     void print()
  332.     {
  333.         cout << "Staff Type: " << staffType << endl;
  334.         cout << "Staff ID: " << staffID << endl;
  335.         cout << "Department ID: " << departmentID << endl;
  336.         Person::printWithOutHome();
  337.     }
  338. };
  339.  
  340. struct Department
  341. {
  342.     string departmentName;
  343.     int departmentID;
  344.  
  345.     Department(string dName = "none", int deptID = 0)
  346.     {
  347.         departmentName = dName;
  348.         departmentID = deptID;
  349.     }
  350. };
  351.  
  352. void departmentMenu();
  353. void staffMenu();
  354. void patientMenu();
  355. /////////////////////////////////////
  356. //// Main
  357. ////////////////////////////////////
  358. int main()
  359. {
  360.  
  361.     char selection;
  362.  
  363.     do
  364.     {
  365.         cout << " Main Menu" << endl;;
  366.         cout << " ====================================" << endl;
  367.         cout << " 1. Department Menu" << endl;
  368.         cout << " 2. Staff Menu" << endl;
  369.         cout << " 3. Patient Menu " << endl;
  370.         cout << " 4. Exit" << endl;
  371.         cout << " ====================================" << endl;;
  372.         cout << " Enter your selection: ";
  373.         cin >> selection;
  374.         cout << endl;
  375.  
  376.         switch (selection)
  377.         {
  378.         case '1':
  379.             departmentMenu();
  380.             system("cls");
  381.             break;
  382.  
  383.         case '2':
  384.             staffMenu();
  385.             system("cls");
  386.             break;
  387.  
  388.         case '3':
  389.             patientMenu();
  390.             system("cls");
  391.             break;
  392.  
  393.         case '4':
  394.             cout << "Goodbye." << endl;
  395.             system("pause");
  396.             return 0;
  397.         default: cout << selection << " is not a valid menu item." << endl;
  398.             cout << endl;
  399.         }
  400.     } while (selection != '4');
  401.  
  402.     return 0;
  403. }
  404.  
  405. /////////////////////////////////////
  406. //// Department Menu
  407. ////////////////////////////////////
  408. void departmentMenu()
  409. {
  410.     ifstream dFile;
  411.     dFile.open("d.txt");
  412.     const int SIZE = 10;
  413.     string deptName;
  414.     int deptID;
  415.     int deptCount = 0;
  416.  
  417.     Department departments[SIZE];
  418.     if (dFile.fail())
  419.     {
  420.         cout << "Error in opening the department file. ";
  421.         system("pause");
  422.     }
  423.     else
  424.     {
  425.         while (getline(dFile, deptName, ','))
  426.         {
  427.             dFile >> deptID;
  428.             dFile.ignore();
  429.  
  430.             departments[deptCount].departmentName = deptName;
  431.             departments[deptCount].departmentID = deptID;
  432.             deptCount++;
  433.         }
  434.     }
  435.  
  436.     char selection;
  437.     do
  438.     {
  439.         system("cls");
  440.         cout << " Department Menu" << endl;
  441.         cout << " ====================================\n";
  442.         cout << " 1. List all departments" << endl;
  443.         cout << " 2. Add one department" << endl;
  444.         cout << " 3. Search one department " << endl;
  445.         cout << " 4. Edit one department " << endl;
  446.         cout << " 5. Delete one department " << endl;
  447.         cout << " 6. Return to main menu" << endl;
  448.         cout << " ====================================" << endl;
  449.         cout << " Enter your selection: " << endl;
  450.         cin >> selection;
  451.         cout << endl;
  452.  
  453.         switch (selection)
  454.         {
  455.         case '1':
  456.             for (int i = 0; i < deptCount; i++)
  457.             {
  458.                 cout << departments[i].departmentName << ", " << departments[i].departmentID << endl;
  459.             }
  460.             system("pause");
  461.             system("cls");
  462.             break;
  463.  
  464.         case '2':
  465.             cout << "Sorry, this feature isn't implemented yet.";
  466.             system("cls");
  467.             break;
  468.  
  469.         case '3':
  470.             cout << "Sorry, this feature isn't implemented yet.";
  471.             system("cls");
  472.             break;
  473.  
  474.         case '4':
  475.             cout << "Sorry, this feature isn't implemented yet.";
  476.             system("cls");
  477.             break;
  478.  
  479.         case '5':
  480.             cout << "Sorry, this feature isn't implemented yet.";
  481.             system("cls");
  482.             break;
  483.  
  484.         case '6':
  485.             system("cls");
  486.             return;
  487.         default: cout << selection << " is not a valid menu item." << endl;
  488.             cout << endl;
  489.         }
  490.     } while (selection != '6');
  491.  
  492. }
  493.  
  494. /////////////////////////////////////
  495. //// Patient Menu
  496. ////////////////////////////////////
  497. void patientMenu()
  498. {
  499.     ifstream pFile;
  500.     pFile.open("p.txt");
  501.  
  502.     string pFirst;
  503.     string pLast;
  504.     int pPatientID;
  505.     int pDoctorID;
  506.     string pBirthDate;
  507.     string pGender;
  508.     int pStreetNumber;
  509.     string pStreet;
  510.     string pCity;
  511.     string pState;
  512.     int pZip;
  513.     string pPhoneNumber;
  514.     string pEmail;
  515.  
  516.     const int pSIZE = 10;
  517.     int pCount = 0;
  518.     Patient patients[pSIZE];
  519.     if (pFile.fail())
  520.     {
  521.         cout << "Error in opening the patient file. ";
  522.         system("pause");
  523.     }
  524.     else
  525.     {
  526.         while (getline(pFile, pFirst, ','))
  527.         {
  528.             getline(pFile, pLast, ',');
  529.             pFile >> pPatientID;
  530.             pFile.ignore();
  531.             pFile >> pDoctorID;
  532.             pFile.ignore();
  533.             getline(pFile, pBirthDate, ',');
  534.             getline(pFile, pGender, ',');
  535.             pFile >> pStreetNumber;
  536.             pFile.ignore();
  537.             getline(pFile, pStreet, ',');
  538.             getline(pFile, pCity, ',');
  539.             getline(pFile, pState, ',');
  540.             pFile >> pZip;
  541.             pFile.ignore();
  542.             getline(pFile, pPhoneNumber, ',');
  543.             getline(pFile, pEmail);
  544.  
  545.             patients[pCount] = { pFirst, pLast, pPatientID, pDoctorID, pBirthDate, pGender, pStreetNumber, pStreet, pCity, pState, pZip, pPhoneNumber, pEmail };
  546.             pCount++;
  547.         }
  548.         pFile.close();
  549.     }
  550.  
  551.     char selection;
  552.  
  553.     do
  554.     {
  555.         system("cls");
  556.         cout << " Patients Menu" << endl;
  557.         cout << " ====================================" << endl;
  558.         cout << " 1. List all patients" << endl;
  559.         cout << " 2. Add one patients" << endl;
  560.         cout << " 3. Search one patients " << endl;
  561.         cout << " 4. Edit one patients " << endl;
  562.         cout << " 5. Delete one patients " << endl;
  563.         cout << " 6. Return to main menu" << endl;
  564.         cout << " ====================================" << endl;
  565.         cout << " Enter your selection: ";
  566.         cin >> selection;
  567.         cout << endl;
  568.  
  569.         switch (selection)
  570.         {
  571.         case '1':
  572.             for (int i = 0; i < pCount; i++)
  573.             {
  574.                 patients[i].print();
  575.                 cout << " " << endl;
  576.                 cout << " " << endl;
  577.                 cout << " " << endl;
  578.             }
  579.             system("pause");
  580.             system("cls");
  581.             break;
  582.  
  583.         case '2':
  584.             cout << "Sorry, this feature isn't implemented yet.";
  585.             system("cls");
  586.             break;
  587.  
  588.         case '3':
  589.             cout << "Sorry, this feature isn't implemented yet.";
  590.             system("cls");
  591.             break;
  592.  
  593.         case '4':
  594.             cout << "Sorry, this feature isn't implemented yet.";
  595.             system("cls");
  596.             break;
  597.  
  598.         case '5':
  599.             cout << "Sorry, this feature isn't implemented yet.";
  600.             system("cls");
  601.             break;
  602.  
  603.         case '6':
  604.             system("cls");
  605.             return;
  606.         default: cout << selection << " is not a valid menu item." << endl;
  607.             cout << endl;
  608.         }
  609.     } while (selection != '6');
  610.  
  611. }
  612.  
  613. /////////////////////////////////////
  614. //// Staff Menu
  615. ////////////////////////////////////
  616. void staffMenu()
  617. {
  618.     ifstream sFile;
  619.     sFile.open("s.txt");
  620.  
  621.     string sType;
  622.     string sFirst;
  623.     string sLast;
  624.     int sStaffID;
  625.     int sDepartmentID;
  626.     string sBirth;
  627.     string sGender;
  628.     string sPhone;
  629.     string sEmail;
  630.  
  631.     const int sSIZE = 10;
  632.     int sCount = 0;
  633.     Staff staff[sSIZE];
  634.     if (sFile.fail())
  635.     {
  636.         cout << "Error in opening the staff file." << endl;
  637.         system("pause");
  638.     }
  639.     else
  640.     {
  641.         while (getline(sFile, sType, ','))
  642.         {
  643.             getline(sFile, sFirst, ',');
  644.             getline(sFile, sLast, ',');
  645.             sFile >> sStaffID;
  646.             sFile.ignore();
  647.             sFile >> sDepartmentID;
  648.             sFile.ignore();
  649.             getline(sFile, sBirth, ',');
  650.             getline(sFile, sGender, ',');
  651.             getline(sFile, sPhone, ',');
  652.             getline(sFile, sEmail);
  653.  
  654.             staff[sCount] = { sType, sFirst, sLast, sStaffID, sDepartmentID, sBirth, sGender, sPhone, sEmail };
  655.             sCount++;
  656.         }
  657.         sFile.close();
  658.     }
  659.  
  660.     char selection;
  661.  
  662.     do
  663.     {
  664.         system("cls");
  665.         cout << " Staff Menu" << endl;
  666.         cout << " ====================================" << endl;
  667.         cout << " 1. List all staff" << endl;
  668.         cout << " 2. Add one staff" << endl;
  669.         cout << " 3. Search one staff " << endl;
  670.         cout << " 4. Edit one staff " << endl;
  671.         cout << " 5. Delete one staff " << endl;
  672.         cout << " 6. Return to main menu" << endl;
  673.         cout << " ====================================" << endl;
  674.         cout << " Enter your selection: ";
  675.         cin >> selection;
  676.         cout << endl;
  677.  
  678.         switch (selection)
  679.         {
  680.         case '1':
  681.             for (int i = 0; i < sCount; i++)
  682.             {
  683.                 staff[i].print();
  684.                 cout << " " << endl;
  685.                 cout << " " << endl;
  686.                 cout << " " << endl;
  687.             }
  688.             system("pause");
  689.             system("cls");
  690.             break;
  691.  
  692.         case '2':
  693.             cout << "Sorry, this feature isn't implemented yet.";
  694.             system("cls");
  695.             break;
  696.  
  697.         case '3':
  698.             cout << "Sorry, this feature isn't implemented yet.";
  699.             system("cls");
  700.             break;
  701.  
  702.         case '4':
  703.             cout << "Sorry, this feature isn't implemented yet.";
  704.             system("cls");
  705.             break;
  706.  
  707.         case '5':
  708.             cout << "Sorry, this feature isn't implemented yet.";
  709.             system("cls");
  710.             break;
  711.  
  712.         case '6':
  713.             system("cls");
  714.             return;
  715.         default: cout << selection << " is not a valid menu item." << endl;
  716.             cout << endl;
  717.         }
  718.     } while (selection != '3');
  719.  
  720. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement