Java代写:IS4415 Clinic Appointments System

代写一个简易的门诊预约系统,用于患者预约医生。

Requirement

In this assignment, you may use your knowledge of the following concepts:

  1. Loops (do-while) and condition flows (if-else if-else)
  2. Calling methods and sending arguments, methods with return types
  3. Creating menu: Reading from console (using Scanner to read from System.in)
  4. Enumeration
  5. Testing for equality of objects
  6. Exception handing using InputMismatchException (you wont need IOException since we are not dealing with external streams to files)
  7. 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
2
3
4
5
6
private final int dID;
private Specialty dSpec = null;
private ArrayList<Appointment> schedule = new ArrayList<>();
private boolean available = true;
private static final int MAXAPPT = 3;
private static int startTime = 9;

Create one constructor with two parameters that will be used to initialize dID and dSpec.

Next, I provide you definitions for the methods:

1
2
3
4
5
public int getID() { }
public Specialty getSpecialty() { }
public boolean isAvailable() { }
public int addToSchedule(Patient patID) { } //this will be method that does the most work
public ArrayList<Appointment> getSchedule() { }

Patient

Create the following fields

1
2
3
private final int pID ;
private Specialty treat =null;
private Appointment appt = null;

Create on constructor with two parameters to initialize the values of pID and treat

Method definitions:

1
2
3
4
public int getID() { }
public Specialty getTreatment() { }
public void setAppt (Appointment info) { }
public Appointment getAppt () { }

Appointment

Create the following fields

1
2
3
private int timeH; //to store the hour 9, 10, 11
private Doctor doctor;
private Patient patient;

Create one constructor with three parameters that will be used to initialize timeH, doctor, and patient

Method definitions:

1
2
public String getApptInfo() { }
//create and return a String with apt time (hour), followed by doctor fields dID and specialty, and patient fields pID and treat

ManageAppt - the main class

Define two global constants that will determine how many doctors and patients to simulate

1
2
final static int DOCSIZE = 5;
final static int PATSIZE = 15;

Method definitions

1
public static void main(String[] args) { }

create two ArrayLists, one for Doctors and one for Patients

1
2
ArrayList<Doctor> docArr = null;
ArrayList<Patient> patArr = 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 class’s nextInt() method.
Create menu options for the following:

1. Simulate
2. View doctors
3. View patients
4. View appointments for a particular doctor
5. View appointments for a particular patient
6. 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 Doctor’s specialty and the Patient’s 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 doctor’s specialty and the patient’s 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. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
4
There are no doctors in the system. Please simulate first.
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
5
There are no doctors in the system. Please simulate first.
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
8
Invalid selection. Try again
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
g
Bad input, please choose a menu option number 1-6
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
1
5 doctors have been created
15 patients have been created
patients rejected due to no doc found = 3
patients rejected due to no appt avaialble = 4
patients assigned an appointment = 8
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
2
printing list of simulated doctors
101 DERM appointments =3
102 CARD appointments =2
103 CARD appointments =0
104 INT appointments =3
105 CARD appointments =0
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
3
printing list of simulated patients
5001 DERM
5002 INT
5003 DERM
5004 INT
5005 CARD
5006 DERM
5007 DERM
5008 DERM
5009 INT
5010 NEUR
5011 NEUR
5012 INT
5013 CARD
5014 NEUR
5015 DERM
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
4
Enter doctor ID to view appointments: 110
sorry that doctor does not exist
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
4
Enter doctor ID to view appointments: 103
Doctor 103, specialty is CARD
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
4
Enter doctor ID to view appointments: 102
Doctor 102, specialty is CARD
9am : doctor = 102 : CARD ; patient = 5005 : CARD
10am : doctor = 102 : CARD ; patient = 5013 : CARD
------------------------------------------------------
Please select from the following options:
1. Simulate
2. View Doctors
3. View Patients 
4. View Appointments for a Doctor
5. Exit from system
------------------------------------------------------
5
Goodbye.