This prelab introduces you to programming in PictureWorld. You will be writing expressions to produce specific Pictures, and you will also be evaluating expressions to predict the resulting Picture.
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 |
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! You will be required to do problems like this on the
exam, so take this opportunity to practice.
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)))));
Time estimates: Do not spend more than 10 minutes on Task 1, 30 minutes on Task 2, and 20 minutes on Task 3. Be sure to try every problem!