![]() |
Lab 7
|
Additionally, there are also versions ofpublic void fd (double n) Move the turtle forward n steps. public void bd (double n); Move the turtle backward n steps. public void lt (double angle); Turn the turtle to the left angle degrees. public void rt (double angle); Turn the turtle to the right angle degrees. public void pu (); Raise the turtle's pen up. public void pd (); Lower the turtle's pen down.
fd
,
bd
, lt
, and rt
that take
int
parameters, so you can invoke these methods
with either an integer or double floating-point value.
You should not need to use any other Turtle primitives other than those listed above. In fact, many solutions use only a subset of the primitives listed above. (Of course, you may enjoy reviewing the turtle contract after you finish.)
For the tasks below, you will test your work by specifying a number of levels and some size (and perhaps an offset) in a parameter window and then clicking on the Run button in the TurtleWorld window. The Reset button will clear the screen.
Good parameter values are in the ranges [0 ... 8] for levels and [100 ... 400] for a size.
As a reminder, make sure to include System.out.println()
statements
in the programs you write. These statements can help you understand how your
program works, and can be a big help in debugging when your program doesn't
work. Each time the method is invoked, a statement is printed to the console pane,
in DrJava.
If your program hangs, you may need to "force quit" it by depressing the option, apple, and escape keys all at the same time. Alternatively, go under the apple menu, and select the "Force Quit" item. If that doesn't help, restart the computer by pressing the little button with the triangle on the machine itself (under your desk, in E101).
Download the lab7_programs
folder from the
cs111d
account on cs.wellesley.edu
.
Most of the programming problems for this lab take place in
extensions of TurtleWorld
. The problems are arranged in
order of difficulty with the easiest problem first. The last problem
is a BuggleWorld recursion problem. Note that the exercises are
challenging, so don't be disappointed if you don't get to all of them during
the lab period. However, you are strongly encouraged to continue working on the
rest on your own, and/or look at the solutions as they become available soon
after the labs are over.