CS 40 Fall 2007 Homework 3

1. Make a world containing a helicopter and two light houses (Beach -> Lighthouse). Add a method circleAround that has a parameter of type Object named target. The method causes the helicopter to circle around the target. Use this strategy for circling:

In World.my_first_method, first have the helicopter call circleAround(lighthouse), then have the helicopter call circleAround(lighthouse2).

20 points.

Grading criteria

a) Does the circleAround method have a parameter of type target?

b) Does the code of the circleAround method always refer to target, never to lighthouse?

c) Does the circling work?

d) Does my_first_method contain two calls to the circleAround method?

2. Make a class CirclingCopter, a helicopter with the circleAround method. (If you were unable to do part 1, just implement the method by having the helicopter say "I wish I could fly in a circle." You'll still get all points for this part.)

Your CirclingCopter should have some color or texture that makes it look different from the regular helicopter.

Make a world with two instances of that class. Have them both circle a single lighthouse (at different heights).

15 points

Grading criteria

a) Is there a class CirclingCopter in this world?

b) Are there two instances of the class in this world?

c) Does my_first_method contain two calls to the circleAround method?

Put two attachments, heli1.a2w and heli2.a2w into the eCampus assignment.