官术网_书友最值得收藏!

Starter

The Starter class includes two class variables, a constructor method, an accessor method, and two methods that toggle the starter on and off. The constructor is used to instantiate copies of the class. The accessor method simply returns the value of the poweredOn variable:

public class Starter {

private WidgetProductionSystem mediator;
private boolean poweredOn;

// Constructor
public Starter(WidgetProductionSystem mediator) {
this.mediator = mediator;
poweredOn = false;

mediator.mediateStarter(this);
}

// accessor
public boolean isSystemOn() {
return poweredOn;
}

public void turnOn() {
poweredOn = true;
mediator.starterPoweredOn();
System.out.println("Mediated Event: Started Powered On");
}

public void turnOff() {
poweredOn = false;
mediator.starterPoweredOff();
System.out.println("Mediated Event: Starter Powered Off");
}
}

Also provided are the turnOn() and turnOff() methods, which simply toggle the value of the powerOn variable.

主站蜘蛛池模板: 钦州市| 花垣县| 谢通门县| 宜阳县| 桃园市| 全南县| 道孚县| 三河市| 宁海县| 城口县| 灵武市| 松江区| 甘洛县| 黄大仙区| 金坛市| 慈溪市| 大冶市| 威远县| 明水县| 吉安县| 射阳县| 南昌县| 象山县| 五原县| 育儿| 西宁市| 陆河县| 三门峡市| 安福县| 三河市| 泸西县| 泸定县| 崇仁县| 嘉义市| 栾城县| 晋宁县| 德化县| 华亭县| 镇赉县| 福泉市| 正镶白旗|