Lab 5

The following exercises are to be completed during lab class.  If you do not have time to finish during lab, they must be completed before the beginning of the following lab session.  You will turn in the lab gradesheet  at the beginning of the following lab.

Before beginning the exercises, copy this lab's folder from the T: drive to your H: drive.

  1. Complete exercise 4.9 on page 208 of your textbook.
    Write the errors on your gradesheet.
     
  2. Write a CountBot class that has a method hasNumThings.
    The method should take a single integer parameter, and return true if the robot has that many things in his backpack and false otherwise.
    Write a main in TestCountBot.java that tests the CountBot class to make sure that it works correctly.
    Include both CountBot.java and TestCountBot.java files to your zipped submit folder.
     
  3. karel is in a completely enclosed rectangular gymnasium where students have left balls out. He is in the northwest corner of the room, which will always be at (1,1), facing east. All of the balls will are next to the walls--none are out in the middle of the room. Create a JanitorBot class with a method cleanUpGym that will go around the room, picking up all of the balls along the walls. The robot should end up back in the northwest corner of the room, facing east. You may assume that there is no more than one ball on any intersection. You may not assume anything about the size of the room. Be sure to use good step-wise refinement in solving this problem. Make sure you test your program with different room sizes. Use the Gym class to help you set up different sized gymnasiums. NOTE: You will need both Gym.java and RectangleCity.java for the Gym class to work. You can find them either on the website or the T drive. Include the JanitorBot.java class to your zipped submit folder.
     

Use the windows zip utility to zip all required files into a single zip folder. Submit the single zip folder to your lab section under project #5 using Web Submit.

NOTE: Do NOT put your files into a folder to be zipped as this will make grading more complicated. Simply select the necessary .java files, right click, choose Send To => Compressed (zipped) Folder.