![]() |
![]() |
![]() |
![]() |
![]() |
|
To do the work, you define the describe
instance method in both the Movie class and the Symphony
class.
At first glance, the following definition of describe in the
Movie class, might seem likely to fail, because there is no target
for either the rating method or the getMinutes method. By
convention, however, because the target and the field-selection operator
are absent, the rating and getMinutes methods are handed the
same class-instance target as that handed to describe. Thus,
rating and getMinutes have implicit targets.
public class Movie extends Attraction {
// Rest of Movie definition
// Define rating:
public int rating () {
return script + acting + direction;
}
// Define describe
public void describe () {
System.out.println(
"Movie with rating "
+ rating() + " lasts "
+ getMinutes() + " minutes"
);
}
}