1. Make a world containing a helicopter (in vehicles folder), a
control tower (buildings folder), and a light house (beach folder). 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:
helicopter.move(helicopter.distance(target) - 10) toward
target
asSeenBy helicopterIn World.my_first_method, first have the helicopter
call
circleAround(lighthouse), then have the helicopter call
circleAround(controlTower).
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 the lighthouse or controlTower?
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, and two different buildings. Have them simultaneously circle different buildings, and after once around their respective buildings, have one of the helicopters join the other, with both now circling a single building (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, helicopter1.a2w and helicopter2.a2w into
an email to taylor@cs.sjsu.edu. Make the subject: CS40 Homework 3
Firstname Lastname, where your name is filled in for firstname
and lastname. Due date: 9/27. Test on 9/30.