Requirement
In this assignment, you may use your knowledge of the following concepts:
- Loops (do-while) and condition flows (if-else if-else)
- Calling methods and sending arguments, methods with return types
- Creating menu: Reading from console (using Scanner to read from System.in)
- Enumeration
- Testing for equality of objects
- Exception handing using InputMismatchException (you wont need IOException since we are not dealing with external streams to files)
- Random number generation
Instructions
Create a project and package called Hw4FirstLastName.java.
In this assignment you will be creating a system to manage patient appointments with Doctors for just one day at a clinic. We will simulate the creation of doctors, patient and appointments. We will make many assumptions in order to simplify the project,
The clinic will have 5 doctors, whose specialties will be randomly picked from among four options: internal medicine, cardiology, neurology and dermatology. There are 15 patients that wish to make appointments on the given day. But doctors can only see these patients between 9 and 12pm, with 3 potential appointments each lasting one hour.
We will create all doctors and patients first, and then attempt to assign patients one by one to open appointments.
Below I will give some information on the classes and methods that you will need.
Specialty
This is an enumeration - a separate file which describes the four types of specialties
Doctor
Define the following fields. Note that they are private in visibility and some are constants (final) and others are constant common to all Doctor objects (static final):
1 | private final int dID; |
Create one constructor with two parameters that will be used to initialize dID and dSpec.
Next, I provide you definitions for the methods:
1 | public int getID() { } |
Patient
Create the following fields
1 | private final int pID ; |
Create on constructor with two parameters to initialize the values of pID and treat
Method definitions:
1 | public int getID() { } |
Appointment
Create the following fields
1 | private int timeH; //to store the hour 9, 10, 11 |
Create one constructor with three parameters that will be used to initialize timeH, doctor, and patient
Method definitions:
1 | public String getApptInfo() { } |
ManageAppt - the main class
Define two global constants that will determine how many doctors and patients to simulate
1 | final static int DOCSIZE = 5; |
Method definitions
1 | public static void main(String[] args) { } |
create two ArrayLists, one for Doctors and one for Patients
1 | ArrayList<Doctor> docArr = null; |
This method will present a menu in a loop to the user and then call other methods for each option. Catch InputMismatchException that could be generated by the Scanner classs nextInt() method.
Create menu options for the following:
1. Simulate2. View doctors3. View patients4. View appointments for a particular doctor5. View appointments for a particular patient6. Exit
When user chooses option 4, ask the user to enter a doctor ID, saved in an int. Then send both the ID entered and the ArrayList of Doctors to method
1 | public static void simulate(ArrayList<Doctor> docList, ArrayList<Patient> patList) { } |
This method will create doctors and patients. Then send them to another method assignAppt(). Use the random class to randomly assign the Doctors specialty and the Patients treat. Assign doctor IDs 101-105, and patient IDs 5001-5015
1 | public static void assignAppt(ArrayList<Doctor> dList, ArrayList<Patient> pList) { } |
To make an appointment, we will first attempt to match a patient to an available doctor based on the doctors specialty and the patients treatment specialty (which will both be assigned one of the four values). If a doctor of the treatment specialty is found, check to see if the doctor is available, and assign patient to the first available appointment. If that doctor is not available, see if there is another doctor of the required specialty.
Keep track of the following: a) how many patients were assigned an appointment, b) how many patients were rejected because no doctor with the desired specialty is present, or c) rejected because all available doctors of the specialty have no appointments available.
1 | public static void printDocInfo(ArrayList<Doctor> dList) { } |
This is a simple method to print Doctor information, sID, specialty and number of appointments booked.
1 | public static void printPatInfo(ArrayList<Patient> pList) { } |
This is a simple method to print Patient information, pID and treat
1 | public static void viewDocAppt(int docIDToSearch, ArrayList<Doctor> docList) { } |
This method accepts an int as an input, ad searches through the list of Doctors. If not found report that, if found, obtain and print the list of appointments (timeH, doctor dID, doctor specialty, patient pID, patient treat)
Submission
Submit a zip file of your project folder Hw4FirstLastname.zip and send it directly from the Canvas assignments area (NOT as an email attachment to me). Happy simulating!
Sample output
------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------4There are no doctors in the system. Please simulate first.------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------5There are no doctors in the system. Please simulate first.------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------8Invalid selection. Try again------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------gBad input, please choose a menu option number 1-6------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------15 doctors have been created15 patients have been createdpatients rejected due to no doc found = 3patients rejected due to no appt avaialble = 4patients assigned an appointment = 8------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------2printing list of simulated doctors101 DERM appointments =3102 CARD appointments =2103 CARD appointments =0104 INT appointments =3105 CARD appointments =0------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------3printing list of simulated patients5001 DERM5002 INT5003 DERM5004 INT5005 CARD5006 DERM5007 DERM5008 DERM5009 INT5010 NEUR5011 NEUR5012 INT5013 CARD5014 NEUR5015 DERM------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------4Enter doctor ID to view appointments: 110sorry that doctor does not exist------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------4Enter doctor ID to view appointments: 103Doctor 103, specialty is CARD------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------4Enter doctor ID to view appointments: 102Doctor 102, specialty is CARD9am : doctor = 102 : CARD ; patient = 5005 : CARD10am : doctor = 102 : CARD ; patient = 5013 : CARD------------------------------------------------------Please select from the following options:1. Simulate2. View Doctors3. View Patients4. View Appointments for a Doctor5. Exit from system------------------------------------------------------5Goodbye.