Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "pch.h"
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- /////////////////////////////////////
- //// PersonalInfo
- ////////////////////////////////////
- class PersonalInfo {
- private:
- string birthDate;
- string gender;
- public:
- PersonalInfo(string birth = "none", string gend = "none")
- {
- birthDate = birth;
- gender = gend;
- }
- void setBirthDate(string b)
- {
- birthDate = b;
- }
- string getBirthDate()
- {
- return birthDate;
- }
- void setGender(string g)
- {
- gender = g;
- }
- string getGender()
- {
- return gender;
- }
- void printPersonalInfo()
- {
- cout << "Birth Date: " << birthDate << endl;
- cout << "Gender: " << gender << endl;
- }
- void printToFilePersonalInfo()
- {
- cout << birthDate << "," << gender;
- }
- };
- /////////////////////////////////////
- //// ContactInfo
- ////////////////////////////////////
- class ContactInfo {
- private:
- string phoneInfo;
- string emailInfo;
- public:
- ContactInfo(string phone = "none", string email = "none")
- {
- phoneInfo = phone;
- emailInfo = email;
- }
- void setPhoneInfo(string p)
- {
- phoneInfo = p;
- }
- string getPhoneInfo()
- {
- return phoneInfo;
- }
- void setEmailInfo(string e)
- {
- emailInfo = e;
- }
- string getEmailInfo()
- {
- return emailInfo;
- }
- void printContactInfo()
- {
- cout << "Phone Info: " << phoneInfo << endl;
- cout << "Email Info: " << emailInfo << endl;
- }
- void printToFileContactInfo()
- {
- cout << phoneInfo << "," << emailInfo;
- }
- };
- /////////////////////////////////////
- //// HomeInfo
- ////////////////////////////////////
- class HomeInfo {
- private:
- int streetNumber;
- string street;
- string city;
- string state;
- int zipCode;
- public:
- HomeInfo(int streetNum = 0, string str = "none", string cit = "none", string stat = "none", int zip = 0)
- {
- streetNumber = streetNum;
- street = str;
- city = cit;
- state = stat;
- zipCode = zip;
- }
- void setStreetNumber(int s)
- {
- streetNumber = s;
- }
- int getStreetNumber()
- {
- return streetNumber;
- }
- void setStreet(string s)
- {
- street = s;
- }
- string getStreet()
- {
- return street;
- }
- void setCity(string c)
- {
- city = c;
- }
- string getCity()
- {
- return city;
- }
- void setState(string s)
- {
- state = s;
- }
- string getState()
- {
- return state;
- }
- void setZipCode(int z)
- {
- zipCode = z;
- }
- int getZipCode()
- {
- return zipCode;
- }
- void printHomeInfo()
- {
- cout << "Address: " << streetNumber << " " << street << ", " << city << ", " << state << " " << zipCode << endl;
- }
- void printToFileHomeInfo()
- {
- cout << streetNumber << "," << street << "," << state << "," << zipCode;
- }
- };
- /////////////////////////////////////
- //// Person
- ////////////////////////////////////
- class Person {
- private:
- string firstName;
- string lastName;
- PersonalInfo personal;
- ContactInfo contact;
- HomeInfo home;
- public:
- 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")
- : personal(birth, gend),
- contact(phone, email),
- home(streetNum, str, cit, stat, zip)
- {
- firstName = first;
- lastName = last;
- }
- //No Home Info Constructor
- Person(string first = "none", string last = "none", string birth = "none", string gend = "none", string phone = "none", string email = "none")
- : personal(birth, gend),
- contact(phone, email)
- {
- firstName = first;
- lastName = last;
- }
- void setFirstName(string f)
- {
- firstName = f;
- }
- string getFirstName()
- {
- return firstName;
- }
- void setLastName(string l)
- {
- lastName = l;
- }
- string getLastName()
- {
- return lastName;
- }
- PersonalInfo getPersonalInfo()
- {
- return personal;
- }
- ContactInfo getContactInfo()
- {
- return contact;
- }
- HomeInfo getHomeInfo()
- {
- return home;
- }
- void print()
- {
- cout << "First Name: " << firstName << endl;
- cout << "Last Name: " << lastName << endl;
- personal.printPersonalInfo();
- contact.printContactInfo();
- home.printHomeInfo();
- }
- void printWithOutHome()
- {
- cout << "First Name: " << firstName << endl;
- cout << "Last Name: " << lastName << endl;
- personal.printPersonalInfo();
- contact.printContactInfo();
- }
- };
- /////////////////////////////////////
- //// Patient
- ////////////////////////////////////
- class Patient : public Person
- {
- private:
- int patientID;
- int doctorID;
- public:
- 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")
- : Person(first, last, birth, gend, streetNum, str, cit, stat, zip, phone, email)
- {
- patientID = patient;
- doctorID = doctor;
- }
- void setDoctorID(int d)
- {
- doctorID = d;
- }
- int getDoctorID()
- {
- return doctorID;
- }
- void setPatientID(int p)
- {
- patientID = p;
- }
- int getPatientID()
- {
- return patientID;
- }
- void print()
- {
- cout << "Patient ID: " << patientID << endl;
- cout << "Doctor ID: " << doctorID << endl;
- Person::print();
- }
- };
- /////////////////////////////////////
- //// Staff
- ////////////////////////////////////
- class Staff : public Person
- {
- private:
- string staffType;
- int staffID;
- int departmentID;
- public:
- 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")
- : Person(first, last, birth, gend, phone, email)
- {
- staffType = staffT;
- staffID = staffI;
- departmentID = departmentI;
- }
- void setStaffType(string staffTy)
- {
- staffType = staffTy;
- }
- string getStaffType()
- {
- return staffType;
- }
- void setStaffID(int staffI)
- {
- staffID = staffI;
- }
- int getStaffID()
- {
- return staffID;
- }
- void setDepartmentID(int deptID)
- {
- departmentID = deptID;
- }
- int getDepartmentID()
- {
- return departmentID;
- }
- void print()
- {
- cout << "Staff Type: " << staffType << endl;
- cout << "Staff ID: " << staffID << endl;
- cout << "Department ID: " << departmentID << endl;
- Person::printWithOutHome();
- }
- };
- struct Department
- {
- string departmentName;
- int departmentID;
- Department(string dName = "none", int deptID = 0)
- {
- departmentName = dName;
- departmentID = deptID;
- }
- };
- void departmentMenu();
- void staffMenu();
- void patientMenu();
- /////////////////////////////////////
- //// Main
- ////////////////////////////////////
- int main()
- {
- char selection;
- do
- {
- cout << " Main Menu" << endl;;
- cout << " ====================================" << endl;
- cout << " 1. Department Menu" << endl;
- cout << " 2. Staff Menu" << endl;
- cout << " 3. Patient Menu " << endl;
- cout << " 4. Exit" << endl;
- cout << " ====================================" << endl;;
- cout << " Enter your selection: ";
- cin >> selection;
- cin.ignore();
- cout << endl;
- switch (selection)
- {
- case '1':
- departmentMenu();
- system("cls");
- break;
- case '2':
- staffMenu();
- system("cls");
- break;
- case '3':
- patientMenu();
- system("cls");
- break;
- case '4':
- cout << "Goodbye." << endl;
- system("pause");
- return 0;
- default: cout << selection << " is not a valid menu item." << endl;
- cout << endl;
- }
- } while (selection != '4');
- return 0;
- }
- /////////////////////////////////////
- //// Department Menu
- ////////////////////////////////////
- void departmentMenu()
- {
- ifstream dFile;
- ofstream outFile;
- dFile.open("d.txt");
- const int dSIZE = 10;
- string deptName;
- int deptID;
- int dCount = 0;
- Department departments[dSIZE];
- if (dFile.fail())
- {
- cout << "Error in opening the department file. ";
- system("pause");
- }
- else
- {
- while (getline(dFile, deptName, ','))
- {
- dFile >> deptID;
- dFile.ignore();
- departments[dCount].departmentName = deptName;
- departments[dCount].departmentID = deptID;
- dCount++;
- }
- }
- char selection;
- do
- {
- system("cls");
- cout << " Department Menu" << endl;
- cout << " ====================================\n";
- cout << " 1. List all departments" << endl;
- cout << " 2. Add one department" << endl;
- cout << " 3. Search one department " << endl;
- cout << " 4. Edit one department *Not Implemented" << endl;
- cout << " 5. Delete one department *Not Implemented" << endl;
- cout << " 6. Return to main menu" << endl;
- cout << " ====================================" << endl;
- cout << " Enter your selection: " << endl;
- cin >> selection;
- cin.ignore();
- cout << endl;
- switch (selection)
- {
- case '1':
- for (int i = 0; i < dCount; i++)
- {
- cout << departments[i].departmentName << ", " << departments[i].departmentID << endl;
- }
- system("pause");
- system("cls");
- break;
- case '2':
- if (dCount <= dSIZE)
- {
- cout << "Enter department name: " << endl;
- getline(cin, departments[dCount].departmentName);
- cout << "Enter department ID: " << endl;
- cin >> departments[dCount].departmentID;
- cin.ignore();
- dCount++;
- }
- else
- {
- cout << "There is no more room!";
- }
- system("pause");
- system("cls");
- break;
- case '3':
- int searchID;
- cout << "Enter Department ID: " << endl;
- cin >> searchID;
- cin.ignore();
- for (int i = 0; i < dCount; i++)
- {
- if (departments[i].departmentID == searchID)
- {
- cout << departments[i].departmentName << ", " << departments[i].departmentID << endl;
- }
- }
- system("pause");
- system("cls");
- break;
- case '4':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '5':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '6':
- outFile.open("d.txt");
- if (outFile)
- {
- // cout << "Debug!!!" << endl;
- // system("pause");
- for (int i = 0; i < dCount; i++)
- {
- outFile << departments[i].departmentName << ", " << departments[i].departmentID << endl;
- }
- }
- outFile.close();
- system("cls");
- return;
- default: cout << selection << " is not a valid menu item." << endl;
- cout << endl;
- }
- } while (selection != '6');
- }
- /////////////////////////////////////
- //// Patient Menu
- ////////////////////////////////////
- void patientMenu()
- {
- ifstream pFile;
- ofstream outFile;
- pFile.open("p.txt");
- string pFirst;
- string pLast;
- int pPatientID;
- int pDoctorID;
- string pBirthDate;
- string pGender;
- int pStreetNumber;
- string pStreet;
- string pCity;
- string pState;
- int pZip;
- string pPhoneNumber;
- string pEmail;
- const int pSIZE = 10;
- int pCount = 0;
- Patient patients[pSIZE];
- if (pFile.fail())
- {
- cout << "Error in opening the patient file. ";
- system("pause");
- }
- else
- {
- while (getline(pFile, pFirst, ','))
- {
- getline(pFile, pLast, ',');
- pFile >> pPatientID;
- pFile.ignore();
- pFile >> pDoctorID;
- pFile.ignore();
- getline(pFile, pBirthDate, ',');
- getline(pFile, pGender, ',');
- pFile >> pStreetNumber;
- pFile.ignore();
- getline(pFile, pStreet, ',');
- getline(pFile, pCity, ',');
- getline(pFile, pState, ',');
- pFile >> pZip;
- pFile.ignore();
- getline(pFile, pPhoneNumber, ',');
- getline(pFile, pEmail);
- patients[pCount] = { pFirst, pLast, pPatientID, pDoctorID, pBirthDate, pGender, pStreetNumber, pStreet, pCity, pState, pZip, pPhoneNumber, pEmail };
- pCount++;
- }
- pFile.close();
- }
- char selection;
- do
- {
- system("cls");
- cout << " Patients Menu" << endl;
- cout << " ====================================" << endl;
- cout << " 1. List all patients" << endl;
- cout << " 2. Add one patients" << endl;
- cout << " 3. Search one patients " << endl;
- cout << " 4. Edit one patients *Not Implemented" << endl;
- cout << " 5. Delete one patients *Not Implemented" << endl;
- cout << " 6. Return to main menu" << endl;
- cout << " ====================================" << endl;
- cout << " Enter your selection: ";
- cin >> selection;
- cin.ignore();
- cout << endl;
- switch (selection)
- {
- case '1':
- for (int i = 0; i < pCount; i++)
- {
- patients[i].print();
- cout << " " << endl;
- cout << " " << endl;
- cout << " " << endl;
- }
- system("pause");
- system("cls");
- break;
- case '2':
- if (pCount <= pSIZE)
- {
- cout << "Enter First Name: " << endl;
- getline(cin, pFirst);
- cin.clear();
- cout << "Enter Last Name: " << endl;
- getline(cin, pLast);
- cin.clear();
- cout << "Enter Patient ID: " << endl;
- cin >> pPatientID;
- cin.ignore();
- cout << "Enter Doctor ID: " << endl;
- cin >> pDoctorID;
- cin.ignore();
- cout << "Enter BirthDay: " << endl;
- getline(cin, pBirthDate);
- cout << "Enter Gender: " << endl;
- getline(cin, pGender);
- cout << "Enter Home Number: " << endl;
- cin >> pStreetNumber;
- cin.ignore();
- cout << "Enter Street: " << endl;
- getline(cin, pStreet);
- cout << "Enter State: " << endl;
- getline(cin, pState);
- cout << "Enter Zip Code: " << endl;
- cin >> pZip;
- cin.ignore();
- cout << "Enter Phone Number: " << endl;
- getline(cin, pPhoneNumber);
- cout << "Enter Email Address: " << endl;
- getline(cin, pEmail);
- patients[pCount] = { pFirst, pLast, pPatientID, pDoctorID, pBirthDate, pGender, pStreetNumber, pStreet, pCity, pState, pZip, pPhoneNumber, pEmail };
- pCount++;
- }
- system("pause");
- system("cls");
- break;
- case '3':
- int searchID;
- cout << "Enter Staff ID: " << endl;
- cin >> searchID;
- cin.ignore();
- for (int i = 0; i < pCount; i++)
- {
- if (patients[i].getPatientID() == searchID)
- {
- patients[i].print();
- }
- }
- system("pause");
- system("cls");
- break;
- case '4':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '5':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '6':
- /*
- outFile.open("p.txt");
- if (outFile)
- {
- cout << "Debug!!!" << endl;
- system("pause");
- for (int i = 0; i < pCount; i++)
- {
- // outFile << patients[i].getFirstName() << "," << patients[i].getLastName() << "," << patients[i].getPatientID() << "," << patients[i].getDoctorID() << "," << patients[i].getPersonalInfo().printToFilePersonalInfo() << "," << patients[i].getHomeInfo().printToFileHomeInfo() << "," << patients[i].getContactInfo().printContactInfo();
- }
- }
- outFile.close();
- */
- system("cls");
- return;
- default: cout << selection << " is not a valid menu item." << endl;
- cout << endl;
- }
- } while (selection != '6');
- }
- /////////////////////////////////////
- //// Staff Menu
- ////////////////////////////////////
- void staffMenu()
- {
- ifstream sFile;
- sFile.open("s.txt");
- string sType;
- string sFirst;
- string sLast;
- int sStaffID;
- int sDepartmentID;
- string sBirth;
- string sGender;
- string sPhone;
- string sEmail;
- const int sSIZE = 10;
- int sCount = 0;
- Staff staff[sSIZE];
- if (sFile.fail())
- {
- cout << "Error in opening the staff file." << endl;
- system("pause");
- }
- else
- {
- while (getline(sFile, sType, ','))
- {
- getline(sFile, sFirst, ',');
- getline(sFile, sLast, ',');
- sFile >> sStaffID;
- sFile.ignore();
- sFile >> sDepartmentID;
- sFile.ignore();
- getline(sFile, sBirth, ',');
- getline(sFile, sGender, ',');
- getline(sFile, sPhone, ',');
- getline(sFile, sEmail);
- staff[sCount] = { sType, sFirst, sLast, sStaffID, sDepartmentID, sBirth, sGender, sPhone, sEmail };
- sCount++;
- }
- sFile.close();
- }
- char selection;
- do
- {
- system("cls");
- cout << " Staff Menu" << endl;
- cout << " ====================================" << endl;
- cout << " 1. List all staff" << endl;
- cout << " 2. Add one staff" << endl;
- cout << " 3. Search one staff " << endl;
- cout << " 4. Edit one staff *Not Implemented" << endl;
- cout << " 5. Delete one staff *Not Implemented" << endl;
- cout << " 6. Return to main menu" << endl;
- cout << " ====================================" << endl;
- cout << " Enter your selection: ";
- cin >> selection;
- cin.ignore();
- cout << endl;
- switch (selection)
- {
- case '1':
- for (int i = 0; i < sCount; i++)
- {
- staff[i].print();
- cout << " " << endl;
- cout << " " << endl;
- cout << " " << endl;
- }
- system("pause");
- system("cls");
- break;
- case '2':
- if (sCount <= sSIZE)
- {
- cout << "Enter Staff Type: \nD - Doctor \nN - Nurse \nA - Administrative Personel" << endl;
- getline(cin, sType);
- cout << "Enter First Name: " << endl;
- getline(cin, sFirst);
- cin.clear();
- cout << "Enter Last Name: " << endl;
- getline(cin, sLast);
- cin.clear();
- cout << "Enter Staff ID: " << endl;
- cin >> sStaffID;
- cin.ignore();
- cout << "Enter Department ID: " << endl;
- cin >> sDepartmentID;
- cin.ignore();
- cout << "Enter BirthDay: " << endl;
- getline(cin, sBirth);
- cout << "Enter Gender: " << endl;
- getline(cin, sGender);
- cout << "Enter Phone Number: " << endl;
- getline(cin, sPhone);
- cout << "Enter Email Address: " << endl;
- getline(cin, sEmail);
- staff[sCount] = { sType, sFirst, sLast, sStaffID, sDepartmentID, sBirth, sGender, sPhone, sEmail };
- sCount++;
- }
- system("pause");
- system("cls");
- break;
- case '3':
- int searchID;
- cout << "Enter Staff ID: " << endl;
- cin >> searchID;
- cin.ignore();
- for (int i = 0; i < sCount; i++)
- {
- if (staff[i].getStaffID() == searchID)
- {
- staff[i].print();
- }
- }
- system("pause");
- system("cls");
- break;
- case '4':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '5':
- cout << "Sorry, this feature isn't implemented yet.";
- system("cls");
- break;
- case '6':
- /*
- outFile.open("s.txt");
- if (outFile)
- {
- cout << "Debug!!!" << endl;
- system("pause");
- for (int i = 0; i < sCount; i++)
- {
- }
- }
- outFile.close();
- */
- system("cls");
- return;
- default: cout << selection << " is not a valid menu item." << endl;
- cout << endl;
- }
- } while (selection != '3');
- }
Add Comment
Please, Sign In to add comment