15-100: Introductory/Intermediate Programming (Section F)
Fall 2006
Exercise   
09/20/2006
Counting and Hurdles
Due:  Monday, September 25
8am

Relevant Reading:

  • Handout from class (not available on line) and class notes
  • Chapters 5 and 6 of  the Karel J. Robot text

Assignment:  (worth 10 exercise points)

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

Use the files in this folder as your basis for this assignment.

SPECIAL NOTES: 
  • You may not use the anyBeepersInBeeperBag() test for this exercise.
  • Do all of this in the Application file.  This is easier than creating a new class (which is extra credit).
a)  Run the program as given and look at the world "hurds1.txt".  You will see a series of hurdles.

b)  Write a program that has the robot start in the lower left corner and place one beeper in each of the first 10 intersections on the first row.

c)  Modify the program to ask the user on how many of the intersections on the first row should the robot  place beepers on (ie, generalize 10).

d)  Modify the program to ask the user how many beepers there should be on each of the intersections.  (ie generalize the above so that there may be more than one beeper on each intersection.)  Put the same number of beepers on each intersection.  (ie, only ask the user for one number of beepers.)

e)  Make sure that the robot starts out with exactly enough beepers to perform the task.

f)  Make sure your program works in any world that has hurdles (ie   hurds1, hurds2, hurds3, and hurds4).  NOTE: hurds1 and hurds2 are straightforward.  Hurds3 and hurds4 require a little more effort.



Extra credit options:
  • Once the first robot is done, have a second robot start from the lower left and place more beepers on the intersections.  One beeper on the first intersection, two beepers on the second intersection, three beepers on the third intersection, etc.
  • Make sure that the second robot starts out with exactly enough beepers to perform the task.
  • Redo the assignment.  This time, create a new robot class with a method called beeperOnNextIntersection that moves the robot to the other side of the wall and places a beeper.    Your Application should now call that method rather than doing everything right there.  This method will in part c have to take a parameter to determine how many beepers to put down.


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-diagonal".   For example, if I were in Section Z, I would rename my folder to be:  "McElfresh-Scott-100Z-diagonal"  (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.