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

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.

主站蜘蛛池模板: 宽城| 甘肃省| 喀喇| 宣武区| 托克逊县| 裕民县| 防城港市| 雅江县| 肥西县| 陕西省| 平乐县| 大兴区| 云和县| 桃江县| 岫岩| 农安县| 浦县| 瑞丽市| 邮箱| 酒泉市| 尚志市| 沅陵县| 澄江县| 图木舒克市| 水富县| 镇原县| 吴堡县| 宜宾县| 威海市| 扶绥县| 米脂县| 贞丰县| 浪卡子县| 正宁县| 修文县| 昌平区| 隆安县| 林州市| 枝江市| 徐州市| 灵武市|