Home Segments Top Top Previous Next

179: Mainline

With rating defined to operate on Movie instances—instead of on script, acting, and direction values—you can rewrite the program in Segment 177 as follows:

public class Demonstrate { 
 public static void main (String argv[]) { 
  Movie m = new Movie(); 
  m.script = 8; m.acting = 9; m.direction = 6; 
  System.out.print("The rating of the movie is "); 
  System.out.println(Movie.rating(m)); 
 } 
}