Question: using java Complete TODO 1 in the class Patient, and TODOs 2 and 3 in the class HospitalmanagementSystem. - Assume that all getters and setters

using java Complete TODO 1 in the class Patient, and TODOs 2 and 3 in the class HospitalmanagementSystem.
- Assume that all getters and setters are appropriately coded for all private attributes of all classes.
- The static method Math.Random() returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
- You can add methods/attributes as you see fit.
- The output of running the main method is provided after the code.
Doctor.java
import java.util.ArrayList;
public class Doctor {
private String name;
private int id;
private double salary;
// a list of patients the doctor currently assigned to.
ArrayList patients=new ArrayList();
public void addPatient(Patient p){
patients.add(p);
}
public Doctor(String name, int id,int salary){
super();
this.name = name;
this.id = id;
this.salary=salary;
}
}
2|7
Patient.java
import java.util.ArrayList;
public class Patient {
private String patientName;
private String patientCode; // unique identification number consisting of 10 digits
private String address;
private int age;
private boolean highPriority; // true if high priority, false if not
static ArrayList codeList=new ArrayList();
public Patient(String patientName, String address, int age){
this.patientName = patientName;
this.patientCode = generatePatientCode();
this.address = address;
this.age=age;
highPriority=false;
}
/*TODO 1: Create the method to generate the patientCode, which consists
of 10 randomly generated numbers.
The generated code should be unique for each patient. */
private String generatePatientCode()
{
}
HospitalManagementSystem.java
3|7
import java.util.ArrayList;
public class HospitalManagementSystem {
ArrayList doctors=new ArrayList();
ArrayList departments =new ArrayList();
ArrayList patientList=new ArrayList();
public void addDoctor(Doctor doc)
{
doctors.add(doc);
}
//TODO 2: write the code for the method to print the total salaries of all doctors.
public double printTotalSalaries(){
}
/* TODO 3: Write a method to return a reference to the most popular doctor. The most
popular doctor is the one who has most appointments. If two doctors have the same
number of patients, you may return a reference to any of them. */
public static void main(String[] args)
4|7
{
HospitalManagementSystem system=new HospitalManagementSystem();
Patient p=new Patient("Mohammed","Qatar",77);
Patient p1=new Patient("Yuki","Japan",40);
Patient p2=new Patient("Nusret","Turkey",50);
Patient p3=new Patient("Michael","USA",20);
Patient p4=new Patient("Ali","Iran",66);
Patient p5=new Patient("Rabeh","Algeria",60);
Patient p6=new Patient("Mathews","Australia",50);
Patient p7=new Patient("Rashid","Jordan",199);
Doctor d1=new Doctor("Amal",50,500);
system.addDoctor(d1);
// Assigning patients to d1
d1.addPatient(p);
d1.addPatient(p1);
d1.addPatient(p2);
Doctor d2=new Doctor("Omar",50,500);
system.addDoctor(d2);
// Assigning patients to d2
d2.addPatient(p4);
d2.addPatient(p5);
d2.addPatient(p6);
d2.addPatient(p7);
Doctor d3=new Doctor("Eman",50,400);
system.addDoctor(d3);
// Assigning patients to d3
d3.addPatient(p3);
d3.addPatient(p4);
d3.addPatient(p5);
d3.addPatient(p6);
d3.addPatient(p7);
// printing total salaries of the doctors
system.printTotalSalaries();
// Printing the name of the most popular doctor.
System.out.print("The Most popular Doctor is: ");
Doctor mostpopular= system.mostPopularDoctor();
System.out.println(mostpopular.getName());
}
}
The output of main is as follows:
Total salaries are 1400.0
The Most popular Doctor is: Eman
Consider the following hospital management system consists of 3 classes; Doctor, Patient, and
HospitalManagementSystem as illustrated in the class diagram below:
 using java Complete TODO 1 in the class Patient, and TODOs

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!