With the abstract rating
method installed in the abstract
Attraction
class, you can use it with an Attraction
variable
that has a value that is a Movie
instance or Symphony
instance; the rating is computed by the methods defined in the Movie
or Symphony
class:
public class Demonstrate { public static void main (String argv[]) { // Movie instance assigned to x: Attraction x = new Movie (7, 7, 7); System.out.println("The movie's rating is " + x.rating()); // Symphony instance assigned to x: x = new Symphony (7, 7, 7); System.out.println("The symphony's rating is " + x.rating()); } } --- Result --- The movie's rating is 21 The symphony's rating is 21