Home Segments Top Top Previous Next

144: Mainline

A sixth virtue of procedure abstraction is that you can easily change the way that a computation is done. If you decide to combine ratings by multiplying, rather than by adding, you can redefine movieRating easily.

public class Movie {
 // Define movieRating:
 public static int movieRating (int s, int a, int d) {
  int result = s * a * d; 
  System.out.print("The rating of the movie is " + result); 
  return result; 
 } 
}