Home Segments Top Top Previous Next

279: Mainline

Most programmers put the public instance variables and methods first, on the aesthetic ground that what is public should be up front and open to view, whereas what is private should not be so up front and not so open to view.

public class Attraction {
 // Define zero-parameter constructor:
 public Attraction () {minutes = 75;}
 // Define one-parameter constructor:
 public Attraction (int m) {minutes = m;}
 // Define getter:
 public int getMinutes () {return minutes;}
 // Define setter:
 public void setMinutes (int m) {minutes = m;}
 // Define private variable:    
 private int minutes;           
}