15-100:
Introductory/Intermediate Programming
(Section F) |
Fall 2006 |
Relevant Reading:
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:
|