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

Constructor

The ControlBox class constructor sets the initial values when an instance of the class is instantiated. The power will be set to off based on the Boolean value of false, and the initial slidervalue will be set to 0:

// Constructor
public ControlBox () {
poweredOn = false; // default value
sliderValue = 0; // default value
}

The ControlBox class constructor does not take any arguments and sets default values.