Exemplo n.º 1
0
        public override void Execute(IAtmMachine atm)
        {
            var inventoryOfSelected = atm.InventoryByBills(_tenders);

            foreach (var tender in _tenders)
            {
                Console.WriteLine($"${tender.Value} - {inventoryOfSelected.BillCount(tender)}");
            }
        }
Exemplo n.º 2
0
        public static IEnumerable <int> GetDenominations(string input, IAtmMachine machine)
        {
            List <int> result = new List <int>();

            string[] inputStr = input.Replace(" ", "").Split('$');

            int bill;

            for (int i = 1; i < inputStr.Count(); i++)
            {
                if (int.TryParse(inputStr[i], out bill) && machine.IsValidBill(bill))
                {
                    result.Add(bill);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public override void Execute(IAtmMachine atm)
        {
            var result = atm.Withdrawal(_amount);

            if (result.IsSuccess)
            {
                Console.WriteLine($"Success: Dispensed ${result.Details.TotalAmount}");
                var balance = atm.MachineBalance();
                DisplayBalance(balance);
            }
            else
            {
                Console.WriteLine($"Failure: {result.FailureReason}");
                // The specification is unclear, in the word document it says every withdrawal should
                // display the atm balance. However the example does not display the balance on a failure.
                // TODO: Talk with stake holder to update requirements or example to be correct.
            }
        }
Exemplo n.º 4
0
 public override void Execute(IAtmMachine atm)
 {
     throw new ApplicationException("Execute on quit command should not happen.");
 }
Exemplo n.º 5
0
 public override void Execute(IAtmMachine atm)
 {
     Console.WriteLine("Failure: Invalid Command");
 }
Exemplo n.º 6
0
 public override void Execute(IAtmMachine atm)
 {
     atm.Restock(AtmInventory.DefaultInventory());
     DisplayBalance(atm.MachineBalance());
 }
Exemplo n.º 7
0
 public AtmMachineManager(IAtmMachine machine)
 {
     _machine = machine;
 }
Exemplo n.º 8
0
 public abstract void Execute(IAtmMachine atm);
 public void Given()
 {
     _atmCard    = new AtmCard();
     _atmMachine = new DemoApp.AtmMachine();
 }