Activity 1.4 - Robot world - inheritance, overriding and overloading

Topic

This exercise allows you to test all the various robot classes that inherit from the simple Robot class, discussed in the course text. It also displays the robot movement graphically on a grid.

Materials

In addition to the Solution document, the project for this exercise contains six classes:

This represents the most complex set of classes we have seen so far. Realistic large commercial systems may contain hundreds or even thousands of classes.

Task

In the test class TestRobot, we have provided code to create the various robot objects and to invoke some of their methods. The program should compile and run already but some kinds of robots will not behave properly. You are to complete the classes SpeedRobot and VariableSpeedRobot.

Instructions

  1. Complete the code for the four methods of the SpeedRobot class, moveNorth, moveSouth, moveEast and moveWest, which override the corresponding methods in the Robot class.
  2. Complete the code for the four methods of the VariableSpeedRobot class, moveNorth, moveSouth, moveEast and moveWest, which overload the corresponding methods in the SpeedRobot class.
  3. Build and run the project and check that both the text output and graphical output are as you would expect, given the statements in the main method of the TestRobot class.