Java - Necesito ayuda con la resolucion de este programa porfavor

 
Vista:
sin imagen de perfil

Necesito ayuda con la resolucion de este programa porfavor

Publicado por Joseph (2 intervenciones) el 20/11/2021 16:54:11
Descripción de la funcionalidad
Se quiere implementar una central de turnos para una guardia.
Para ello se quiere guardar en una colección los turnos médicos
Hay 3 tipos diferentes de turnos:
Emergency
Medium
Control
La colección se debe ordenar primero los turnos Emergency, luego los Médium y por último los Control. Si dos turnos tienen el mismo orden de llegada se ordena mediante el id del turno (El mínimo id va primero).
El método “getShift” es para sacar un turno de la cola, mientras el método “setShift” es para colocar un nuevo turno en la colección
Cada turno cuando se quita de la colección de turnos es asignado a un médico.
Los médicos que están libres para atender se almacenan en otra colección y la misma está ordenada en el orden de llegada.
El método .patientsInOrder() es para mostrar a todos los pacientes que haya atendido un doctor en orden alfabético por el nombre del paciente (No puede haber repetidos).
El método .record() es para mostrar a los pacientes en conjunto con los turnos que hayan tenido.
En la creación de un paciente se coloca su dni, su nombre y su código de la credencial.
En la creación de un médico profesor se coloca su dni, su nombre y su especialidad.
En la creación del turno se coloca un id identificatorio del turno, el paciente y el tipo de turno
. No hace falta pensar en el caso de que un médico pueda ser paciente


public static void main(String[] args) {
Doctor House = newDoctor(123,"Gregory House","Nephrology and Infectology");
Doctor Cuddy = newDoctor(456,"Lisa Cuddy","endocrinology");
Patient Brandon = new Patient(789,"Brandon",1);
Patient Rebecca = new Patient(1011,"Rebecca",2);
Patient John = new Patient(1213,"John Henry Giles",3);
Patient Victoria = new Patient(1415,"Victoria Matson",4);
Patient Keith = new Patient(1616,"Keith",5);
MedicalShifts medicalShifts1 = new MedicalShifts(1,Brandon,TypeOfShift.CONTROL);
MedicalShifts medicalShifts2 = new MedicalShifts(2,Rebecca,TypeOfShift.MEDIUM);
MedicalShifts medicalShifts3 = new MedicalShifts(3,John,TypeOfShift.CONTROL);
MedicalShifts medicalShifts4 = new MedicalShifts(4,Victoria,TypeOfShift.EMERGENCY);
MedicalShifts medicalShifts5 = new MedicalShifts(5,Keith,TypeOfShift.EMERGENCY);

MedicalShiftsManagment medicalShiftsManagment = new MedicalShiftsManagment();

medicalShiftsManagment.addDoctor(House);
medicalShiftsManagment.addDoctor(Cuddy);
medicalShiftsManagment.setShift(medicalShifts1);
medicalShiftsManagment.setShift(medicalShifts2);
medicalShiftsManagment.setShift(medicalShifts3);
medicalShiftsManagment.setShift(medicalShifts4);
medicalShiftsManagment.setShift(medicalShifts5);

try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) { System.out.println( e.getMessage() );
}

medicalShiftsManagment.addDoctor(House);
medicalShiftsManagment.addDoctor(Cuddy);

while(!medicalShiftsManagment.isEmptyOfShifts() && !medicalShiftsManagment.isEmptyOfDoctors()){
try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}
}
medicalShiftsManagment.addDoctor(House);
try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

medicalShiftsManagment.addDoctor(Cuddy);
try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

MedicalShifts medicalShifts6 = new MedicalShifts(6,John,TypeOfShift.EMERGENCY);
MedicalShifts medicalShifts7 = new MedicalShifts(7,Victoria,TypeOfShift.MEDIUM);
MedicalShifts medicalShifts8 = new MedicalShifts(8,Keith,TypeOfShift.CONTROL);

medicalShiftsManagment.setShift(medicalShifts6);
medicalShiftsManagment.setShift(medicalShifts7);
medicalShiftsManagment.setShift(medicalShifts8);

System.out.println(medicalShiftsManagment.record());

medicalShiftsManagment.addDoctor(House);

try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

medicalShiftsManagment.addDoctor(House);

try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

medicalShiftsManagment.addDoctor(House);
try {
System.out.println(medicalShiftsManagment.getShift());
} catch (Exception e) {
System.out.println( e.getMessage() );
}

System.out.println(House.patientsInOrder());
}


OUTPUT:


Shift from: Victoria Matson, Type of Shift: Emergency
Shift from: Keith, Type of Shift: Emergency
Unfortunately there are no doctors available
Shift from: Rebecca, Type of Shift: Medium
Shift from: Brandon, Type of Shift: Control
Shift from: John Henry Giles, Type of Shift: Control
There are no more patients
{Patient name: Brandon, Credential Number: 1=[Shift from: Brandon, Type of Shift: Control], Patient name: Rebecca, Credential Number: 2=[Shift from: Rebecca, Type of Shift: Medium], Patient name: John Henry Giles, Credential Number: 3=[Shift from: John Henry Giles, Type of Shift: Control, Shift from: John Henry Giles, Type of Shift: Emergency], Patient name: Victoria Matson, Credential Number: 4=[Shift from: Victoria Matson, Type of Shift: Emergency, Shift from: Victoria Matson, Type of Shift: Medium], Patient name: Keith, Credential Number: 5=[Shift from: Keith, Type of Shift: Emergency, Shift from: Keith, Type of Shift: Control]}
Shift from: John Henry Giles, Type of Shift: Emergency
Shift from: Victoria Matson, Type of Shift: Medium
Shift from: Keith, Type of Shift: Control
[Patient name: John Henry Giles, Credential Number: 3, Patient name: Keith, Credential Number: 5, Patient name: Rebecca, Credential Number: 2, Patient name: Victoria Matson, Credential Number: 4]
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder