P26. (Appointments)
Write a class to store appointments. Your
Appointment class should store the beginning
and ending time of the appointment, and a short
description of the appointment (stored as a string).
The Appointment class should also contain the
following constructors:
- the default constructor that sets the beginning
and ending time to noon and the description to
the empty string,
- a constructor that takes a string for the
description and sets the time to the current
time,
- a constructor whose first argument is a string
for the description and second and third arguments
are of type Time and store the beginning
and ending time, respectively, of the appointment.
and the following accessor and mutator methods:
- public String toString()
- public void setDescription(String s)
- public String getDescription()
- public void setBeginningTime(Time t)
- public Time getBeginningTime()
- public void setEndingTime(Time t)
- public Time getEndingTime()
Write a program that demonstrates that your class works.
Have your program ask the user for an appointment, store
this in an Appointment object, and then print
out the appointment.
Your program should:
- Ask the user for the beginning time of the appointment.
The time will be entered as 6 integers representing the
year, the month, the day, the hour, the minute, and the
second of the beginning time.
- Ask the user for the ending time of the appointment.
The time will be entered as 6 integers representing the
year, the month, the day, the hour, the minute, and the
second of the ending time.
- Ask the user for a short description of the appointment.
Note that this could consist of several words, so, you
should read the entire line, instead of a single word.
You should include
comments for each of your functions that can be used by
javadoc to generate documentation (see notes from
class or Appendix A for more details about using
javadoc).
This class will be used later for a daily planner
program-- which will use the above methods.
The current program should be console-based.
Submit this as program 26
using the electronic submission. Please call the
file (and the class) Program26.
Program 27 is cancelled, due to system difficulties!
P27. (Animation)
Modify animate.java to
allow the user to control the length of time the
images are seen on the screen. You should have a
choice button with the choices: "fast", "medium",
and "slow."
Include start and stop buttons that will start and
stop your animation. For example:
Submit this as program 27
using the electronic submission. Please call the
file (and the class) Program27.
Include an HTML file in the directory called Program27.html
that displays your applet and any images your applet
uses.
P28. (Puzzle)
Write a class called PuzzleBoard.
PuzzleBoard should store 15 PuzzlePieces
(see Homework 7, P19) and include the
following methods:
- a default constructor that initializes the 15
pieces as in the demonstration below.
- a method that draws the puzzle pieces and the
"Scramble" box.
- a move method that takes a point as its input.
If the point is contained in the "Scramble" box,
it calls a second (private) method with a randomly
chosen position 1000 times. The purpose is to
scramble the pieces, so the puzzle can be played.
Your class should use the PuzzlePiece class written
for P19.
PuzzleBoard will be called by
Program28.java.
For more information and hints, see here.