st2main.cpp

来自「c#设计模式WithCla」· C++ 代码 · 共 62 行

CPP
62
字号
#include "controll.h"
#include <iostream.h>
#include <cstring.h>

int main ()
{
/* 
  //Use with ST2STATE.OMT and ST2HEAD1.SCT, ST2FUNC1.SCT, ST2HEAD2.SCT, and ST2FUNC2.SCT        
  Controller controller1;
  try {
		 controller1.process (turnOn);}
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }

  try {
		 controller1.process (turnOff); }
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }
  return 0;
*/

  //Use with ST2STATE.OMT and ST2HEAD3.SCT and ST2FUNC3.SCT, ST2HEAD5.SCT, ST2FUNC5.SCT 
  Controller controller1;
  try {
		 controller1.turnOn (1);  }
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }

  try {
		 controller1.turnOff (); }
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }

  return 0;
/*
  //Use with ST2STATE.OMT and ST2HEAD4.SCT and ST2FUNC4.SCT     
  pOffState = new OffState();
  pOnState = new OnState();
  State *pCurrentState;
  pCurrentState = pOffState;
  
  try {
		 pCurrentState = pCurrentState->turnOn(1); }
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; } 

  try {     
		 pCurrentState = pCurrentState->turnOff(); } 
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }  

  return 0;
*/
/*
  //Use with ST2STATE.OMT and ST2HEAD5.SCT and ST2FUNC5.SCT 	
  Controller controller1;	
  try {
	 controller1.turnOn(1); }
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; } 

  try {     
	 controller1.turnOff(); } 
  catch (string eventError) { cout << eventError << "Cannot process event" << endl; }  

  return 0;
*/
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?