| Karel is in a completely enclosed rectangular
room that has, unfortunately, litter strewn all over it (see the sample room
given below). Create a new class of robot that can pick up the litter. This
robot is a child of Robot. The
room is always 4 intersections wide and 3 intersection high.
Karel always starts in the top-left corner and maybe facing any
direction. You must turn and face east before you start cleaning up.
Karel should move back to its starting location when its task is
complete. It should then face north.
Examine the Robot documentation
to find out how to make the city display the number of things that are on
each intersection.
You must make one new method that will pick up all of the items that are on
the intersection. You can assume that there is no more than 4 pieces of litter on any
intersection. As you move the robot in the city, use the new method on each
intersection. Create two different city files that contain:
- the walls; and
- a different number of pieces of
litter and in different locations
so that you can test your robot. |