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

Power-related methods

Two methods are required to manage power—powerOn() and powerOff():

// Method to turn power on
public void powerOn() {
poweredOn = true;
}

// Method to turn power off
public void powerOff() {
poweredOn = false;
}

The preceding methods serves a toggles for the poweredOn variable.