1. Implement a class named Appointment that contains: • A private String data field named patientName. A private static int data field named newID. This value will be automatically incremented with the creation of each Appointement object. The initial value of newlD is 1. • A private constant (final) int data field named APPOINTEMENT_ID. • A private int data field named day. The value represents the day of the week from 1 to 5, (1 for Monday, 2 for Tuesday, and so on till Friday). • A private int data field named hour. Accepted values are 8, 9, 10, ...14 • 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. • The accessor (getter) methods for patientName and APPOINTEMENT_ID. • 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. • The method getDayOfTheWeek returns a string representing the day of the week. For instance, if the day is 1, the method returns "Monday". If the day is 2, it returns "Tuesday" and so on. If the day is 0, the method returns "Undefined". • The method getApprointmentDetails that returns a string representation of the approintment. It contains the appointment ID, the patientName followed by a dash followed by the day of the week and the hour. For example: Appointment #1: The patient is HassanMohana - Monday at 10 o'clock. Write a main program to: - Create two different appointment. The first appointment object is for patient "MayaMrouch" on “Thursday" at “13 pm". The second appointment object is read from the user. Write the code to check if the two appointments conflict in day and time. If so it prints a message "The two appointments are set for the same day and day". And moves one of the appointments to the next day. Write the code to display the appointments information using the method getApprointmentDetails.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter4: More Object Concepts
Section: Chapter Questions
Problem 11PE
icon
Related questions
Question

java program

1. Implement a class named Appointment that contains:
• A private String data field named patientName.
• A private static int data field named newID. This value will be automatically
incremented with the creation of each Appointement object. The initial value of newlID
is 1.
• A private constant (final) int data field named APPOINTEMENT_ID.
• A private int data field named day. The value represents the day of the week from 1 to
5, (1 for Monday, 2 for Tuesday, and so on till Friday).
• A private int data field named hour. Accepted values are 8, 9, 10, ...14
• A constructor that creates a new appointment with specific patient Name given as
argument. Then, the appointment will be immediately assigned a APPOINTEMËNT_ID
according to newID.
• The accessor (getter) methods for patientName and APPOINTEMENT_ID.
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.
• The method getDayOfTheWeek returns a string representing the day of the week. For
instance, if the day is 1, the method returns "Monday". If the day is 2, it returns
"Tuesday" and so on. If the day is 0, the method returns “Undefined".
• The method getApprointmentDetails that returns a string representation of the
approintment. It contains the appointment ID, the patientName followed by a dash
followed by the day of the week and the hour. For example:
Appointment #1: The patient is HassanMohana - Monday at 10 o'clock.
Write a main program to:
- Create two different appointment. The first appointment object is for patient
"MayaMroueh" on “Thursday" at “13 pm". The second appointment object is read
from the user.
Write the code to check if the two appointments conflict in day and time. If so it
prints a message "The two appointments are set for the same day and day". And
moves one of the appointments to the next day.
Write the code to display the appointments information using the method
getApprointmentDetails.
Transcribed Image Text:1. Implement a class named Appointment that contains: • A private String data field named patientName. • A private static int data field named newID. This value will be automatically incremented with the creation of each Appointement object. The initial value of newlID is 1. • A private constant (final) int data field named APPOINTEMENT_ID. • A private int data field named day. The value represents the day of the week from 1 to 5, (1 for Monday, 2 for Tuesday, and so on till Friday). • A private int data field named hour. Accepted values are 8, 9, 10, ...14 • A constructor that creates a new appointment with specific patient Name given as argument. Then, the appointment will be immediately assigned a APPOINTEMËNT_ID according to newID. • The accessor (getter) methods for patientName and APPOINTEMENT_ID. 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. • The method getDayOfTheWeek returns a string representing the day of the week. For instance, if the day is 1, the method returns "Monday". If the day is 2, it returns "Tuesday" and so on. If the day is 0, the method returns “Undefined". • The method getApprointmentDetails that returns a string representation of the approintment. It contains the appointment ID, the patientName followed by a dash followed by the day of the week and the hour. For example: Appointment #1: The patient is HassanMohana - Monday at 10 o'clock. Write a main program to: - Create two different appointment. The first appointment object is for patient "MayaMroueh" on “Thursday" at “13 pm". The second appointment object is read from the user. Write the code to check if the two appointments conflict in day and time. If so it prints a message "The two appointments are set for the same day and day". And moves one of the appointments to the next day. Write the code to display the appointments information using the method getApprointmentDetails.
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
void method
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage