void Start() { char problem = 'c'; //switch (problem) //{ // case 'a': // new DMHandlerA().Handle(); // break; // case 'b': // new DMHandlerB().Handle(); // break; // default: // break; //} DMHandlerA handlerA = new DMHandlerA(); DMHandlerB handlerB = new DMHandlerB(); DMHandlerC handlerC = new DMHandlerC(); //handlerA.nextHandler = handlerB; //handlerB.nextHandler = handlerC; handlerA.SetNextHandler(handlerB) .SetNextHandler(handlerC); handlerA.Handle(problem); }
private void Awake() { char problem = 'a'; DMHandlerA handlerA = new DMHandlerA(); DMHandlerB handlerB = new DMHandlerB(); DMHandlerC handlerC = new DMHandlerC(); handlerA.SetNextHandler(handlerB).SetNextHandler(handlerC); handlerA.DoHandle(problem); }
// Use this for initialization void Start() { char problem = 'a'; // switch(problem){ // case 'a': // new DMHandlerA().Handle(); // break; // case 'b': // new DMHandlerB().Handle(); // break; // } DMHandlerA handlerA = new DMHandlerA(); DMHandlerB handlerB = new DMHandlerB(); handlerA.SetNextHandler(handlerB).SetNextHandler(handlerB); handlerA.Handle(problem); }