Programming Assignment #3
Due: February 27, 2004
Description - Design and implement an applet with the following functionality:
- Defines a "room" or search area. (probably just the dimensions of the applet)
- Defines a single goal. (probably just another filled rectangle)
- Defines robots that move around the scene (again, probably just differently colored squares).
There will be three types of robots, all which inherit from a common ancestor:
- Horizontal Robot (moves horizontally)
- Vertical Robot (moves vertically)
- Diagonal Robot (moves diagonally)
The robots will move around the scene looking for the goal. The robots will start in a random location
and move at the same speed.
If a horizontal or vertical robot bumps into a wall (edge of room or search area),
it will change direction 90 degrees, move
a small distance up/down/left/right (depending on the type of robot),
change direction another 90 degrees (making a total of a 180 degree turn), and
continue searching. If it gets to the bottom/top/left/right of the room without finding the goal,
it will start back the
other way. A diagonal robot will change direction 90 degrees clockwise or counterclockwise
(depending on its current direction and the position it hits the wall), and continue moving.
When a robot finds the goal, the program ends. Note that robots do not
have to detect if they collide with one another.
Deliverables: The "documented" .java files.
Points: 100 points
Hint: Look up the Rectangle class, particularly the intersects method.