CS111, Wellesley College, Fall 2006

Lab 3

Wedn/Thur September 20/21, 2006

Today:


Exercise 1: An Invocation Tree

Draw an invocation tree (an abbreviated version of a Java Execution Model) for the execution of the SPW.makePattern(p), where SPW symbolizes the SimplePictureWorld object that receives the method invocation and p denotes the blue triangle Picture object (shown below).

Each node contains the value of the receiver, followed by the method name, followed by the actual parameters enclosed in parentheses. The result of invoking the method is then shown after a colon. Note that nodes at the same level are drawn from top to bottom in the order that the methods are invoked.



EXERCISE 2: Escher Knitting Patterns

Please download the folder lab3_programs from the download directory on cs111 server.

Escher used two basic patterns to produce an amazing variety of patterns:


A(red,blue,green,yellow,magenta)


B(red,blue,green,yellow,magenta)

Below are three practice knitting patterns to figure out. The skeletons for the methods are in the LabKnitWorld.java file.

Your Task
Fill in the code for these methods to obtain the patterns. Consult Picture World contract if necessary.


labKnit1(Color.red, Color.green)


labKnit2(Color.magenta, Color.blue)


labKnit3(Color.blue, Color.red,
Color.cyan, Color.magenta)