Problem

For the following exercises, use the incremental development methodology to implement th...

For the following exercises, use the incremental development methodology to implement the program. For each exercise, identify the program tasks, create a design document with class descriptions, and draw the program diagram. Map out the development steps at the start. Present any design alternatives and justify your selection. Be sure to perform adequate testing at the end of each development step.

In the Turtle exercises from the earlier chapters, we dealt with only one Turtle (e.g., see Exercise 28 on page 144). It is possible, however, to let multiple turtles draw on a single drawing window. To associate multiple turtles to a single drawing, we create an instance of TurtleDrawingWindow and add turtles to it as follows:

TurtleDrawingWindow canvas = new TurtleDrawingWindow( );

Turtle winky, pinky, tinky;

//create turtles;

//pass Turtle.NO_DEFAULT_WINDOW as an argument so

//no default drawing window is attached to a turtle.

winky = new Turtle(Turtle.NO_DEFAULT_WINDOW);

pinky = new Turtle(Turtle.NO_DEFAULT_WINDOW);

tinky = new Turtle(Turtle.NO_DEFAULT_WINDOW);

//now add turtles to the drawing window

canvas.add( winky );

canvas.add( pinky );

canvas.add( tinky );

Ordinarily, when you start sending messages such as turn and move to a Turtle, it will begin moving immediately. When you have only one Turtle, this is fine. However, if you have multiple turtles and want them to start moving at the same time, you have to first pause them, then give instructions, and finally command them to start moving. Here’s the basic idea:

winky.pause( );

pinky.pause( );

tinky.pause( );

//give instructions to turtles here,

//e.g., pinky.move(50); etc.

//now let the turtles start moving

winky.start( );

pinky.start( );

tinky.start( );

Using these Turtle objects, draw the following three triangles:

Use a different pen color for each triangle. Run the same program without pausing and describe what happens.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4