- Hands-On Design Patterns with Java
- Dr. Edward Lavieri
- 51字
- 2021-06-24 14:58:06
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.