15-100: Introductory/Intermediate Programming (Section F)
Fall 2006
Exercise   
09/29/2006
Parameters
Due:  Friday, October 6
8am

Relevant Reading:

  • Handout from class (not available on line) and class notes
  • By now, you should have read Chapters 1,2,3,5, and 6 of Karel J Robot.
  • Skim Chapters 1 and 3 of Head First Java.  Also, Chapter 5, pages 105-112 has some potentially useful stuff at this point, too.  However, it relies on some stuff we have not done yet.
  • Other readings in other references you may have (eg.  the Pohl download)

Assignment:  (worth 10 exercise points)

Get the ex09-29.zip file.  Use the files in this folder as your basis for this assignment.

In the Application file, you will see that in main, a bunch of the code has been "commented out" - comment markers have been inserted so that the program will ignore them.   There are 4 sections to the program, with 4 robots.


a)  Create the file MultiRobot so that the robot joe does what it is supposed to.   The Application file should not change to get this to work.

b)  Take out the comment marks around the code for the robot karel.     Now, modify the file MultiRobot so that the robot karel does what it is supposed to.   The Application file should not change to get this to work - except for removing the comment marks.   Make sure that joe still does the right thing.

c)  Take out the comment marks around the code for the robot jane.     Now, modify the file MultiRobot so that the robot jane does what it is supposed to.   The Application file should not change to get this to work - except for removing the comment marks.  Make sure that joe and karel still do the right thing.

 d)  Take out the comment marks around the code for the robot scott.     If you did parts a, b, and c correctly, the program should run correctly now.  If it does not, modify the file MultiRobot so that the robot scott does what it is supposed to.   The Application file should not change to get this to work - except for removing the comment marks.  Make sure that joe, karel, and mary still do the right thing.


AT THIS POINT, ALL FOUR ROBOTS SHOULD DO THEIR ASSIGNED TASK.

 e)   Add a fifth robot to the Application that starts in the lower right corner of the screen, facing west.  The robot puts a beeper on one intersection in that row, and moves north a row.  The last two intersections in that row get a beeper, and then the robot moves north a row, and repeats.  In the end, the robot will have put beepers on the last i intersections of row i for all rows.     Make your code as short and succinct as possible.

 f)    Create a new file Application2.java that does the SAME THING as Application.java, but uses for loops instead of while loops.    To compile and run, you will need to replace "Application"  with  "Application2" in the command line AND in the public class Application implements Directions line of the file.    For your submission, include both Application.java and Application2.java.

Handin:
  • Be sure to read the general handin instructions on the exercises page.
  • Rename the folder containing all of the files to be "lastname-firstname-100SectionLetter-params".   For example, if I were in Section Z, I would rename my folder to be:  "McElfresh-Scott-100Z-params"  (without the quotes).   
  • Create a zip file of this folder, with the same name as the folder (except with the .zip ending this time). Instructions for zipping can be found in the system and software handouts linked on the main course page.
  • Submit this file via the electronic handin.  If you have problems, contact me.