Home Segments Top Top Previous Next

298: Mainline

Now, suppose that you want to define constructors for the Movie class and for the Symphony class that assign only the minutes instance variable. You could, of course, define the constructors as follows:

public class Movie extends Attraction { 
 ... 
 public Movie (int m) {minutes = m;}    <-------* 
 ...                                            | 
}                                               | 
                                                | Duplicates 
public class Symphony extends Attraction {      | 
 ...                                            | 
 public Symphony (int m) {minutes = m;}    <----* 
 ... 
}