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

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.

主站蜘蛛池模板: 光山县| 绥阳县| 英吉沙县| 烟台市| 信丰县| 兰坪| 安宁市| 壤塘县| 揭阳市| 商丘市| 侯马市| 琼中| 青海省| 济南市| 庄河市| 榆林市| 沐川县| 阿拉善右旗| 龙海市| 山西省| 新沂市| 麻栗坡县| 云安县| 元谋县| 花莲市| 章丘市| 汶川县| 甘谷县| 宣城市| 兴仁县| 宁晋县| 新巴尔虎右旗| 蕉岭县| 茶陵县| 罗田县| 武清区| 榆社县| 吕梁市| 永登县| 冀州市| 淳化县|