コード例 #1
0
 public void ManageMoney(string playerInput, SodaMachine sodaMachine)
 {
     if (playerInput == "cancel")
     {
         Console.WriteLine("\n\n****Transaction canceled.  Refunding money.****\n\n");
         sodaMachine.ReturnChange(wallet);
     }
     else if (playerInput == "grape" || playerInput == "orange" || playerInput == "lemon")
     {
         sodaMachine.BuySoda(playerInput, wallet);
     }
     else
     {
         Money change = new Money();
         change = change.DetermineMoney(playerInput);
         if (change.worth == penny.worth)
         {
             wallet.pennies.RemoveAt(0);
             sodaMachine.insertedCoins.Add(change);
         }
         if (change.worth == nickel.worth)
         {
             wallet.nickels.RemoveAt(0);
             sodaMachine.insertedCoins.Add(change);
         }
         if (change.worth == dime.worth)
         {
             wallet.dimes.RemoveAt(0);
             sodaMachine.insertedCoins.Add(change);
         }
         if (change.worth == quarter.worth)
         {
             wallet.quarters.RemoveAt(0);
             sodaMachine.insertedCoins.Add(change);
         }
     }
 }
コード例 #2
0
 public SodaMachineUi(SodaMachine machine)
 {
     this.machine = machine;
     this.Controllers.Push(new MainMenu(machine));
 }