A private String data field named patientName.
b) A private int data field named newID. This value will be automatically incremented with the creation of
each Appointement object. The initial value of newID is 1.
c) A private constant (final) int data field named APPOINTEMENT_ID.
d) A private int data field named dayhe value represents the day of the week from 1 to 5, (1 for Monday, 2
for Tuesday, and so on till Friday).
e) A private int data field named hour. Accepted values are 8, 9, 10, …14
f) A constructor that creates a new appointment with specific patient Name given as argument. Then, the
appointment will be immediately assigned a APPOINTEMENT_ID according to newID.
g) The accessor (getter) methods for patientName and APPOINTEMENT_ID.
h) The accessor and mutator (setter) methods for the day and hour fields. Note that if the day value is not in
[1,5] then the field is set 0. Also, if the hour is not in [8,14], the field value is set to 0.
public class Appointement {
private String patientName;
private static int newID = 1;
private final int APPOINTEMENT_ID;
private int day;
private int hour;
public Appointement(String Name){
this.patientName = Name;
this.APPOINTEMENT_ID = this.newID;
newID++;
}
public String getPatientName(){
return this.patientName;
}
public int getAPPOINTEMENT_ID(){
return this.APPOINTEMENT_ID;
}
public void setDay(int number){
if(number==1 ||number==2||number==3||number==4||number==5){
this.day = number;
}
else {
this.day = 0;
}
}
public void setHour(int hour){
if(hour==8 ||hour==9||hour==10||hour==11||hour==12||hour==13||hour==14){
this.hour = hour;
}
else {
this.hour = 0;
}
}
}
Comments
Leave a comment