Write a Java class named
representing appointments you make. You will be
modeling the equivalent of a real world appointment using Java.
This class should include several pieces of data as instance variables:
day of the week: (integer with 0 representing Sunday and 6 representing Saturday)
who the appointment is with (String)
duration of the appointment (double)
start time of the appointment (double with 0.0 representing midnight, 12.0 representing noon, and
(for example) 15.0 representing 3pm. For this assignment, you can assume all appointments
begin either on the hour or on the half-hour.)
The Appointment class will have several methods
get/set methods for each instance variable (all of which should be declared private).
3 constructors: a default constructor with no parameters, a constructor with 4 parameters (day,
start time, duration, and person
in that order
), and a copy constructor which makes a new object
from the current state of another object (passed as a parameter).
method. As discussed in class, this method is very useful for working with (and
debugging!) objects and object variables. It should return a reasonable representation of the
object based on the instance variable values, but the exact format of that String is up to you.
which takes a new start time and a new duration and updates the current
which takes an Appointment object as a parameter. This function
returns a boolean value based on whether or not the current appointment and the parameter
variable appointment conflict with each other. For the purposes of this assignment, a conflict is
defined as two appointments on the same day of the week whose times overlap by some amount.
Testing your solution:
You will need to write a class, say
, which instantiates (creates) a
number of Appointment object variables and tests your functions above. How you write this file
is entirely up to you, as it is strictly for your own testing purposes.