hts.StevenWood.com

[ Last Page ]

Karel 8

Complete the following in class or for homework.

1. Design the RobotTask class and all needed Robot classes for the following problem. Make sure that they are all in the same directory. (Also make sure that you have no workspace open.)

RedRobot and BlueRobot are children of UpAndDownRobot.

a) Create the UpAndDownRobot so that it contains a variable called spacesMove(d). This variable will keeps track of how many spaces an UpAndDownRobot moves.

b) Create RedRobot. It starts out with the colour black. As it moves each space it become more red. (Each space makes it more red by 15 units.)  RedRobot  will need to override the move() method to keep track of the number of spaces each has moved.

It will also need a mutator method that will adjust the colour.

c) Create BlueRobot. It starts out with the colour black. As it moves each space it become more blue. (Each space makes it more blue by 15 units.)  BlueRobot  will need to override the move() method to keep track of the number of spaces each has moved.

It will also need a mutator method that will adjust the colour.

d) Create a test class that will use the city file TwinPeaks.txt. One robot is to start at avenue 1, street 5 and a second robot is to start at avenue 11, street 5. 

The first robot (RedRobot) is climb over the hill and pick up all the Things.

Move RedRobot to the intersection of the second robot (BlueRobot) and drop all of the things.

BlueRobot, the second robot, will take all the Things dropped by the first robot. 

The second robot will climb over the second hill and drop Things at each step, as it goes. As it moves it become more blue. 

Test your program thoroughly. Document task code and new robot class properly.

Do NOT hand in your work unless other instructions were given.

 

Initial Situation:

 

 

 

 

 

 

 

Final Situation:

 

 

 

 

 

 

 

    
[Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+