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 Router(WendingMachine machine) { _machine = machine; _state = new DefaultState(this); _dependencies = new Dictionary <Type, object>() { { typeof(WendingMachine), _machine }, { typeof(Router), this } }; }
public GetChange(WendingMachine machine) { _machine = machine; }
public AddMoney(WendingMachine machine, int money) { _machine = machine; _money = money; }
public BuyGood(WendingMachine machine, IOrder order) { _machine = machine; _order = order; }