2019-10-30 14:54:41 +00:00
|
|
|
|
#include <iostream>
|
|
|
|
|
#include "CommandPattern.h"
|
|
|
|
|
|
|
|
|
|
int main()
|
|
|
|
|
{
|
|
|
|
|
// ʵ<><CAB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD><DFA3><EFBFBD>ť
|
|
|
|
|
Button *button = new Button();
|
|
|
|
|
Command *lampCmd, *fanCmd;
|
|
|
|
|
|
|
|
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>
|
|
|
|
|
lampCmd = new LampCommand();
|
|
|
|
|
button->setCommand(lampCmd);
|
|
|
|
|
button->touch();
|
|
|
|
|
button->touch();
|
|
|
|
|
button->touch();
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
|
|
|
|
|
|
|
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|
|
|
|
fanCmd = new FanCommand();
|
|
|
|
|
button->setCommand(fanCmd);
|
|
|
|
|
button->touch();
|
|
|
|
|
button->touch();
|
|
|
|
|
button->touch();
|
|
|
|
|
|
|
|
|
|
#ifdef COMMAND_QUEUE
|
|
|
|
|
|
|
|
|
|
printf("\n\n***********************************\n");
|
|
|
|
|
Button2 *button2 = new Button2();
|
|
|
|
|
Command *lampCmd2, *fanCmd2;
|
|
|
|
|
CommandQueue *cmdQueue = new CommandQueue();
|
|
|
|
|
|
|
|
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD>Ƶ<EFBFBD><C6B5><EFBFBD>
|
|
|
|
|
lampCmd2 = new LampCommand();
|
|
|
|
|
cmdQueue->addCommand(lampCmd2);
|
|
|
|
|
|
|
|
|
|
// <20><>ť<EFBFBD><C5A5><EFBFBD>Ʒ<EFBFBD><C6B7><EFBFBD>
|
|
|
|
|
fanCmd2 = new FanCommand();
|
|
|
|
|
cmdQueue->addCommand(fanCmd2);
|
|
|
|
|
|
|
|
|
|
button2->setCommandQueue(cmdQueue);
|
|
|
|
|
button2->touch();
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
printf("\n\n");
|
2020-11-29 03:17:40 +00:00
|
|
|
|
|
|
|
|
|
delete button;
|
|
|
|
|
delete lampCmd;
|
|
|
|
|
delete fanCmd;
|
|
|
|
|
delete button2;
|
|
|
|
|
delete lampCmd2;
|
|
|
|
|
delete fanCmd2;
|
|
|
|
|
|
2019-10-30 14:54:41 +00:00
|
|
|
|
system("pause");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|