Пример #1
0
int main()
{
    Light lightA;
    LightOnCommand lightOnCommand(lightA);
    OutdoorLight outdoorLight;
    OutdoorLightOnCommand outdoorLightOnCommand(outdoorLight);
    SimpleRemoteControl simpleRemoteControl;
    simpleRemoteControl.setCommand(&lightOnCommand);
    simpleRemoteControl.buttonPressed();
    simpleRemoteControl.setCommand(&outdoorLightOnCommand);
    simpleRemoteControl.buttonPressed();
    return 0;
}
Пример #2
0
int _tmain(int argc, _TCHAR* argv[])
{
	SimpleRemoteControl remote;
	Light light;
	Garage garage;
	LightOnCommand* lighton = new LightOnCommand(light);
	GarageDoorOpenCommand* garageDoor = new GarageDoorOpenCommand(garage);
	remote.setCommand(lighton);
	remote.buttonWasPressed();
	remote.undoButton();
	remote.setCommand(garageDoor);
	remote.buttonWasPressed();
	remote.undoButton();
	delete garageDoor;
	delete lighton;
	garageDoor = NULL;
	lighton = NULL;
	return 0;
}