![]() |
Lab 4
|
Please download the folder lab4_programs
from the
directory on cs111d
account on puma
.
WallHugger
world from lecture (where the Buggle hugs the wall).
You can run the applet
WallHuggerWorld here.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.
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,
|
Using only the methods in the PictureWorld contract, write (on paper) the expressions which will return the following Pictures:
|
|
|
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 theLabQuiltWorld.java
file.
|
|