void flipdown( ) {
downcommand . execute ( );
}
}
class lightoncommand implements command {
private light mylight;
public lightoncommand ( light l) {
mylight = l;
}
public void execute( ) {
mylight . turnon( );
}
}
class lightoffcommand implements command {
private light mylight;
public lightoffcommand ( light l) {
mylight = l;
}
public void execute( ) {
mylight . turnoff( );
}
}
class fanoncommand implements command {
private fan myfan;
public fanoncommand ( fan f) {
myfan = f;
}
public void execute( ) {
myfan . startrotate( );
}
}
class fanoffcommand implements command {
private fan myfan;
public fanoffcommand ( fan f) {
myfan = f;
}
public void execute( ) {
myfan . stoprotate( );
}
}
public class testcommand {
public static void main(string[] args) {
light testlight = new light( );
lightoncommand testloc = new lightoncommand(testlight);
lightoffcommand testlfc = new lightoffcommand(testlight);
switch testswitch = new switch(testloc,testlfc);
testswitch.flipup( );
testswitch.flipdown( );
fan testfan = new fan( );
fanoncommand foc = new fanoncommand(testfan);
fanoffcommand ffc = new fanoffcommand(testfan);
switch ts = new switch( foc,ffc);
ts.flipup( );