Answer to Question #316559 in Java | JSP | JSF for LAYLA

Question #316559

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 dayhe 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.


1
Expert's answer
2022-03-23T16:18:16-0400
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;
        }
    }
}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS