P2+exercise

Patient: code format="java" public class Patient { private int id; private String name; private int priority; private String doctor;

public Patient(int i, String n, int p){ id = i;		name = n;		priority = p;		doctor = null; }	public void setId(int i){id = i;} public void setName(String n){name = n;} public void setPriority(int p){priority = p;} public void setDoctor(String d){doctor = d;} public int getId{return id;} public String getName{return name;} public int getPriority{return priority;} public String getDoctor{return doctor;} public String toString{return id+" "+name+" "+priority+" "+doctor;} }

code Waiting Room:

code format="java" public class WaitingRoom { private Patient[] patients = new Patient[10];

public void add(Patient newPatient){ int i = 0; while((patients[i] != null)&&(i < 10)) {			i++; }		if(i == 10){System.out.println("No more space in the waiting room");} else{patients[i] = newPatient;} }

public void callNextPatient {		int index = 0; if(patients[0] == null) {			System.out.println("The waiting room is empty"); }		else {			index = findNextPatientIndex; remove(index); }	}

private void remove(int n) { System.out.println(patients[n]); for(int i = n+1; i < 10; i++){ patients[i-1] = patients[i];

}		patients[9] = null; }

private int findNextPatientIndex { int max = 0; int i = 1; while((i<10)&&(patients[i]!=null)){ if(patients[i].getPriority > patients[max].getPriority){ max = i;			} i++; }		return max; }

}

code Treatment: code format="java" public class Treatment { String date; int patientId; String doctor; String actions; String medications; public Treatment{

}	public void setDate(String date){ this.date = date; }	public void setPatientId(int id){ patientId = id; }	public void Doctor(String doctor){ this.doctor = doctor; }	public void setActions(String actions){ this.actions = actions; }	public void setMedications(String med){ medications = med; }	public String getDate{return date;} public int getpatientId{return patientId;} public String getDoctor{return doctor;} public String getActions{return actions;} public String getMedications{return medications;} public String toString{return date+" "+patientId+" "+doctor+" "+actions+" "+medications;} }

code result4: code format="java"

public double result4 { public result4(double x, int y, double z, int v){ if(x+y+z>12*v){ result(v,y); }		else if(2*y < x){ return result4(x,y-3,z,v-3); }		else{result(0,0);} }

private int result(int x, int y) { if(x == 0){return 0;} else if(y == 0){return 1;} else{return (x+y)*result(x,y-1);}

} } code