CS 4773 Object Oriented Programming, Spring 2000
Assignment 4
Due Friday, March 24
In this assignment you are to design and implement an applet which will
move an arbitrary number of rectangles in straight lines across the screen.
Here are some of the things the applet should do.
- The applet will be of size 600 by 400.
- All rectangles will have a width of 50 and a height of 25.
- There should be a way of entering the current travel time.
- There should be a way of choosing the current color.
At a minimum the choices red, green, and blue should be available.
- Pushing down the mouse button will cause the rectangle of the current
color to be displayed at the mouse location.
- Dragging the mouse will draw a rubber line of the current color
from the starting point to the
current mouse position. (The rectangle does not move.)
- When the mouse button is lifted, the line remains in place and the
rectangle smoothly moves along the line at a constant rate. The total
time for the move is the current travel time
(at the time the movement started).
- The applet should display your name in such a way that it will not be
covered up by the rectangles.
- There should be a way of clearing all of the rectangles off the screen
so that you can start over.
- The applet should keep track of the total number of rectangles and the
total number of rectangles that are still moving. This information should
be displayed on such a way that it is not obscured by the rectanges.
- Changing the current color or current travel time will not affect the
rectangles already drawn.
- The position of a rectangle is its upper left corner.
- Your algorithm for moving along a line should hit every pixel along the
line.
- The number of threads used should be independent of the number of
rectangles being displayed.
- Be careful of synchronization issues.
Do an object oriented design for this and make CRC cards for the classes.
The CRC cards do not have to be on index cards.
Implement this design and make sure that it will work as an applet
run from a browser.
Put your final applet on the web with a link to it from your course
web page.
Turn in your complete source and CRC cards. Use the cover page in
/usr/local/courses/cs4773/spring2000/cover4.ps.