CS111, Wellesley College, Fall 2006

Lab 4

Wedn/Thur September 27/28, 2006


Today:

Please download the folder lab4_programs from the directory on cs111d account on puma.

Part I: Debugging GoHomeWorld

Recall WallHugger world from lecture (where the Buggle hugs the wall). You can run the applet WallHuggerWorld here.
Remember that WallHuggerWorld uses the tick() method in order to repeat a block of code over and over again.

Your first task today is to make GoHomeWorld run succesfully. GoHomeWorld is very much like WallHuggerWorld,
with the exception that the Buggle stops when it is back at point (1,1).

You can see how your solution should work by running GoHomeWorld.html in the Test folder.

To start this task, open GoHomeBuggle.java in the GoHomeBuggle folder and work through the code to get it to compile.
Think about the best way to make your buggle stop back at position (1,1).
Remember that you can always use the console window to get more insight into your code.

Part II

EXERCISE: Simple QuiltWorld Patterns

First, a gentle introduction to quilting (Tasks 1a & 1b):

Task 1a Suppose you are given the following black box method:

public Picture triangle (Color c)
Returns a Picture of a triangle of the specified Color whose vertices are at (0,0), (1,0), and (0,1).

For example,


triangle(Color.green);

Using only the methods in the PictureWorld contract, write (on paper) the expressions which will return the following Pictures:


picture 1


picture 2


picture 3


Task 1b

Evaluate the following expressions. Draw (on paper) the Picture that each represents. Indicate the colors in whatever way is convenient (colored pencils, markers,etc.). Do not write a program to run on the computer to show you the pictures; do it by hand!

picture 4

overlay(clockwise90(triangle(Color.blue)),triangle(Color.blue));

picture 5

above(fourSame(flipDiagonally(triangle(Color.yellow))),
      beside(triangle(Color.green),
             above(empty(), flipVertically(triangle(Color.green)))));


Task 1c

Below are two quilt designs for you to figure out. The skeletons for the methods are in the LabQuiltWorld.java file.


diamonds()


fourColors()