Project #1
Due Date: Start of lecture, Thursday, Sept. 15, 2005
The objective of this first project is to do a few programs using the
Java Spider, just to get you started in developing with Java in an
entertaining way. Project 2 will begin a sequence of projects that are
based on textbook material and have very different submission
requirements.
Part A.
Copy programs53/WalkLine.java into your csci53
directory; compile and run it. Now make a duplicate copy of WalkLine.java
and call it Project1A.java. Hint: use this UNIX command:
cp WalkLine.java Project1A.java
Now modify Project1A.java into a program that causes the
Spider to move to the right ("eastward") from its starting position,
and leave a trail of four green marks with one colorless mark between
each pair. The result should look like G . G . G . G *
starting from the center of the room. Hint: use the Spider.changeColor
method to alternate between Spider.GREEN and Spider.NONE.
Part B.
Now duplicate Project1A.java, call it Project1B.java,
and modify it so that the spider draws the same pattern, but the four
steps are controlled by a counting loop instead of repeated lines of
code. Hint: the loop body should be a green step followed by a
colorless step.
Part C.
Now duplicate Project1B.java into Project1C.java,
and modify it so the spider draws a "checkerboard" pattern like this:
G . G . G . G G . G . G . G G . G . G . G G . G . G . G *
Part D:
Finally, compile and run programs53/TourRoom.java, then
duplicate it into Project1D.java, and modify it so the spider
leaves a colorless trail till it reaches the first wall, then goes all
the way around the room and stops when it has completely visited all
four walls.
What to submit:
For this project, submit
a signature sheet (print this from the website)
a copy of this page as a problem specification
a printout of the listing (.txt) file for each of the
programs
Your grade will be calculated on a 20-point basis, 5 points per part.