Hands-On Design Patterns with Java
上QQ阅读APP看书,第一时间看更新

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.