public override string Execute(string[] command, State state)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();

            if (command.Length != 2)
            {
                sb.AppendLine("This command requires state ( state <customer | kitchen | foh> )");
            }
            else
            {
                StateFactory factory = StateFactory.GetInstance;
                switch (command[1].ToLower())
                {
                case "kitchen":
                    state.Context.ChangeState(factory.GetState("kitchen"));
                    sb.AppendLine("State Change to Kitchen.");
                    break;

                case "foh":
                    state.Context.ChangeState(factory.GetState("foh"));
                    sb.AppendLine("State Change to Front Of House.");
                    break;

                default:
                    state.Context.ChangeState(factory.GetState("customer"));
                    sb.AppendLine("State Change to Customer.");
                    break;
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 2
0
        public override void Execute(Order o)
        {
            StateFactory stateFactory = StateFactory.GetInstance;

            StateFOH stateFOH = (StateFOH)stateFactory.GetState("foh");

            stateFOH.WaitExceededOrders.Add(o);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Context      context = new Context();
            StateFactory factory = StateFactory.GetInstance;
            ServiceDB    db      = ServiceDB.GetInstance;

            context.ChangeState(factory.GetState("customer"));

            Console.WriteLine(context.Run(""));
        }
        public override string Execute(string[] command, State state)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine();

            StateFactory factory = StateFactory.GetInstance;
            StateFOH     foh     = (StateFOH)factory.GetState("foh");

            sb.AppendLine(foh.CompleteOrdersToString());

            return(sb.ToString());
        }
        public void CompleteOrder(int index)
        {
            KeyValuePair <Order, Timer> pair = OrderList.ElementAt(index - 1);
            Timer t = pair.Value;

            t.Stop();
            t.Dispose();
            OrderList.Remove(pair.Key);

            StateFactory stateFactory = StateFactory.GetInstance;
            StateFOH     foh          = (StateFOH)stateFactory.GetState("foh");

            pair.Key.Status = "Served";
            foh.CompleteOrders.Add(pair.Key);
        }