예제 #1
0
        static void Main(string[] args)
        {
            WendingMachine machine = new WendingMachine(balance: 0,
                                                        goods: new Good[] {
                new Good("Шоколадка", price: 70, count: 5),
                new Good("Газировка", price: 60, count: 2)
            }
                                                        );
            ICommandInput input = new ConsoleCommandInput(new Router(machine));

            while (true)
            {
                Console.Clear();
                Console.WriteLine($"Баланс {machine.Balance}");

                var command = input.GetCommand();
                if (command == null)
                {
                    Console.WriteLine("Команда не распознана");
                }
                else
                {
                    command.Execute();
                }
                Console.ReadKey();
            }
        }
 public BuyGood(WendingMachine machine, IOrder order)
 {
     _machine = machine;
     _order   = order;
 }
예제 #3
0
 public Router(WendingMachine machine)
 {
     _machine = machine;
     _state   = new DefaultState(this);
 }
예제 #4
0
 public AddMoney(WendingMachine machine, int money)
 {
     _machine = machine;
     _money   = money;
 }
 public GetChange(WendingMachine machine)
 {
     _machine = machine;
 }