Hospital Interface - Java. Instructions: For this project, you will build a hosp
ID: 3844202 • Letter: H
Question
Hospital Interface - Java.
Instructions:
For this project, you will build a hospital interface, where you can:
- Login
- List patients
- Add patients
- See patient records
- Add/remove records for a patient.
You will be reading data from multiple files:
- employees.txt will be responsible for managing user login. (file will be provided)
- patients.txt will be responsible for managing the list of patients (file will be provided)
- Each patient will have their own file with their records. For example, Anne will have a anne.txt with her records, Tim will have tim.txt with his records, and so on.
Suggested way to tackle this homework:
- Start by downloading all the files.
- View the files to see all the formats.
- Read the employees from employees.txt
o Create a new employee for each line.
o Add the employees to the employees ArrayList of the hospital.
- Read the patients from patients.txt
o Create a new patient for each line.
o For each patient
Read their designated records.
• For each line, create a record and add it to the records ArrayList.
o Add the patient to the patients ArrayList of the hostpital.
- At this point, you have a hospital, with employees, patients.
- Write down the menu, with the appropriate switch / if/else statement.
- List_patients should be straightforward.
- View_records, you’ll need a way to find the patient from the patients array list
- Add_record should be straightforward.
- Remove_record, you’ll need a way to find the patient from the patients array list and then find the record from the records array list.
- Add_patient. You’ll need to add this user to the patients.txt and create a record file for them. Suppose you add Thomas, you will have to create a thomas.txt file to hold their records.
- Finally upon program exit (when the user enters 0), write back the data.
- Start with the patients, iterate over all the patients and write them down to patients.txt
o For each patient, get the records and write it down to the appropriate file. Anne’s records go in to anne.txt, etc.
Skeleton Code:
import java.util.ArrayList;
import java.util.Scanner;
import java.io.File;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import java.text.DateFormat;
class Patient {
private String name;
private ArrayList records;
Patient(String name) {
this.name = name;
this.records = new ArrayList();
}
}
class Record {
private String disease;
private String date;
Record(String disease, String date) {
this.disease = disease;
this.date = date;
}
}
class Employee {
private String name;
private String password;
private String type;
Employee(String name, String password, String type) {
this.name = name;
this.password = password;
this.type = type;
}
}
class Hospital {
private String name;
private String location;
private ArrayList employees;
private ArrayList patients;
Hospital(String name, String location) {
this.name = name;
this.location = location;
this.employees = new ArrayList();
this.patients = new ArrayList();
}
}
public class HospitalInterface {
private static Hospital hospital;
public static void main(String[] args) throws Exception {
hospital = new Hospital("SFSU Trauma Center", "Holloway");
System.out.println("SFSU Trauma Center at Holloway");
}
}
Text Files:
employees.txt
name - password - position
name - password - position
patients.txt
Anne
Time
John
anne.txt
fever-05/14/2017 14:43:25
congestion-05/14/2017 15:07:10
tim.txt
cough-02/20/2016 16:43:25
Explanation / Answer
doctor class: or employee
//patiet class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.