Home Segments Top Top Previous Next

292: Mainline

You could, of course, define the required four-parameter constructor as follows, duplicating the assignment statements of the three-parameter constructor and adding a statement that assigns the minutes instance variable:

public class Movie extends Attraction { 
 public int script, acting, direction; 
 public Movie () {script = 5; acting = 5; direction = 5;} 
 public Movie (int s, int a, int d) {  
  script = s; acting = a; direction = d;  <-------* 
 }                                                | Duplicates 
 public Movie (int s, int a, int d, int m) {      | 
  script = s; acting = a; direction = d;  <-------* 
  minutes = m; 
 }  
 public int rating () {return script + acting + direction;} 
}