Project 2: Inheritance

This project is designed to teach about using inheritance as a mechanism for organizing code well.


Goal: (From Horstmann text, pg. 513) Your task is to program robots with varying behaviors. The robots try and escape a maze, such as the following:

A robot has a position and a method void move(Maze m) that modifies the position. Provide a common superclass Robot whose move method does nothing. Provide subclasses RandomRobot, RightHandRobot and MemoryRobot. Each robot has a different behavior. RandomRobot makes random moves. RightHandRobot moves so that its right hand is always touching a wall. MemoryRobot remembers every position it has ever visited, and never goes back to a position that it knows to be a dead end.

Keys to success:

  1. Think before you code.
  2. Clear and appropriate separation between what is in the Robot class, what belongs in the various Robot subclasses, and test code.
    (Hint: draw pictures or a UML diagram.)
  3. Informative comments in the code and in the generated Javadoc.
  4. Write code to test the robot classes before you write the robot classes.