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

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.

主站蜘蛛池模板: 浮山县| 保康县| 铁岭县| 太湖县| 赫章县| 铜陵市| 邢台市| 宁南县| 樟树市| 莎车县| 邵阳县| 甘肃省| 赣榆县| 琼海市| 合水县| 乌拉特中旗| 邢台县| 武平县| 奉贤区| 宜昌市| 龙门县| 澄江县| 靖边县| 临猗县| 五寨县| 两当县| 临夏市| 施秉县| 荥经县| 洱源县| 重庆市| 屏山县| 儋州市| 白朗县| 龙里县| 团风县| 双鸭山市| 菏泽市| 沂南县| 浦东新区| 射洪县|