The program starts with showing output "1. Admit Patient 2. Discharge Patient 3. Display Patients 4. Exit" and asks for a number as an input . If user enters any other number except these 4, it will show "Invalid Number, please try again"
A if else check will ensure we can call the correct function to do out desired operation. #1 will admit patient, #2 will discharge patient, #3 will display the existing patients and #4 will exit the program.
The program ensures all the edge ccases are handled properly and it wouldn't crash because of any invalid input.
We will declare a class named "Patient" and we will keep this public here so that it's accessible from everywhere of this program. We will take a string for name, an integer for age and another string for the disease name.
We are using a vector to save the data of the patients.
We will have a constructor named Patient as well, which will create objects and then help us to push them in the existing vector.
In admitPatient function, we will show output "Enter Patient Name, age & disease" and then take input of name, age and disease of the patient.
Afterwards, we will use a constructor to construct an object and then push that into the vector.
After the operation is completed, it will show a output "Patient admitted successfully"
In dischargePatient function, we will show output "Enter patient name to discharge:" and then take input the name of the patient.
Afterwards, we will use an iterator to iterate through the vector to find the desired patient if we can find the patient, we will erase the patient details.
After the operation is completed, it will show a output "Patient discharged successfully"
Incase, if we can't find the patient, it will show output "Patient not found."
In displayPatients function, we will show output "No patients to display" if there's no patient in the vector.
If we have patients in the vector, we will use a loop to show output the patients' details like following:
Patient's Name:
Patient's Age:
Patient's Disease: