Exercise
08/30/2006
|
Carpeting Hallways
|
Due: Friday, September 1 8am
|
Relevant Reading:
- Chapters 1 and 2 of the Karel J. Robot text.
- On-line references for using the
software.
Next Reading:
- Chapter 3 of the Karel J. Robot text - we'll
be doing this material on Friday, so read ahead.
Assignment: (worth 10 exercise points)
For this homework, you will use the computer and the Java language to create your first computer program in the course.
Get the ex08-30.zip file. Use the
files
in this folder as your basis for this assignment.
Run the program as given and see the world that you are
given. In this world are 4 "hallways" indicated by wall
segments. You are to write a program that has 4 robots
"carpet" those hallways by placing one beeper on each intersection
within the hallways.
Detailed Specifications:
- There must be a separate robot responsible for each hallway.
- Each Robot object must start or begin outside of the hallway.
- Each Robot object must finish or end outside of the hallway.
- The carpet must consist of one beeper per intersection and only one beeper per intersection (beepers are expensive).
- Each Robot object must be turned off when the program terminates (the cost of energy is high).
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.
- Start this early. You don't want to wait till Thursday night to start
and find you are having difficulties after I have gone home and CA help
hours are over.
- 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/Application.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/Application.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-hallways". For example, if I were in Section Z, I would rename my folder to
be: "McElfresh-Scott-100Z-hallways"
(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.
|