Exercise
09/01/2006
|
Picking Fields
|
Due: Friday, September 8 8am
(due date corrected to Friday from Thursday)
|
Relevant Reading:
- Chapter 3 of the Karel J. Robot text
Assignment: (worth 10 exercise points)
Get the ex09-01.zip file. Use the
files
in this folder as your basis for this assignment.
This
program creates 4 robots that are facing rectangles of
beepers. Using this as your start, write a program
that has the robots pick up all of the beepers that are on the screen
in the rectangles, AND go to the lower left corner of the screen and
shut off. (All four robots should go to the lower left
corner.) The world "field.txt" is part of the zip download.
You will need to create a "PickerRobot" class. This class should
have new instructions (also known as "methods") to make the task
easier. The code in the Application.java file should be
relatively short, as should each new instruction that the "PickerRobot"
has.
You may want to extend the TurningRobot class we created in
class. If so, you will need to move the TurningRobot.java file
into the folder with Application.java for this exercise.
Additional requirements:
-
In the comment at the top of
each file that you create or modify, be sure to put your name, course
number, and section letter.
-
At the top of the
PickerRobot.java file, you should add to the comment what instructions
you have added to the robot.
Notes:
- Think through how you will approach the problem rather than
just blindly starting to type code. Plan out what you will do on paper and
then fill in the details on the computer.
- Remember that you are permitted to talk with others in this section
regarding
how the program works. However, you need to do the actual work
yourself
and understand the answer that you produce.
- When
editing your programs on a PC, you will probably NOT want to use the
Notepad application. Wordpad or other text editors should be
fine, but Notepad can cause odd behaviors.
- In order to compile and execute your program:
- For the Macintosh World
- Open a Terminal window. Change the directory (using the cd command) to the ex08-30 directory.
- to compile: javac -classpath .:KarelJRobot.jar kareltherobot/*.java
- to run: java -cp .:KarelJRobot.jar kareltherobot.Application
- For the Windows World
- Open a Command prompt window (under Accessories). Change the directory (using the cd command) to the ex08-30 directory.
- to compile: javac -classpath .;KarelJRobot.jar kareltherobot/*.java
- to run: java -cp .;KarelJRobot.jar kareltherobot.Application
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-fields". For example, if I were in Section Z, I would rename my folder to
be: "McElfresh-Scott-100Z-fields"
(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.
|