- Hands-On Design Patterns with Java
- Dr. Edward Lavieri
- 54字
- 2021-06-24 14:58:06
Accessor methods
There are only two variables that require accessor methods—sliderValue and poweredOn. Accessor methods for those variables are provided here:
// Accessor Methods
public int getSliderValue() {
return sliderValue;
}
public boolean hasPower () {
return poweredOn;
}
The accessor methods just shown can also be referred to as getter methods.