Home Segments Top Top Previous Next

276: Mainline

Note, however, that all instance methods in the Attraction class have access to private instance variables declared the Attraction class definition. Thus, attempts to access an attraction's instance-variable values from outside the Attraction class, via public instance methods, are successful:

x.getMinutes()    <-- Access compiles;  
                      getMinutes is a public method 
x.setMinutes(6)   <-- Assignment compiles;  
                      setMinutes is a public method