public void FeedMoney(decimal dollars) { VendingFileWriter vfw = new VendingFileWriter(); vfw.WriteToLog("FEED MONEY: $" + balance + " $" + (balance + dollars)); this.balance += dollars; }
public VendableItem Purchase(string slot) { if (!IsSoldOut(slot)) { if (items[slot][0].Price <= this.balance) { VendableItem selection = items[slot][0]; VendingFileWriter vfw = new VendingFileWriter(); vfw.WriteToLog($"{items[slot][0].Name} {slot} $" + balance + " $" + (balance - items[slot][0].Price)); balance -= items[slot][0].Price; purchasedItems.Add(items[slot][0]); items[slot].Remove(items[slot][0]); return(selection); } else { Console.WriteLine("Insufficient funds. Please insert more money!"); return(null); // return nothing because not enough money! } } else { Console.WriteLine("Item is sold out. Please select something else."); return(null); //return nothing because it is sold out } }
public void CompleteTransaction() //placeholder { ChangeMaker c = new ChangeMaker(this.balance); c.MakeChange(); VendingFileWriter vfw = new VendingFileWriter(); vfw.WriteToLog("Give Change: " + balance + " " + ("$0.00")); this.balance = 0; foreach (VendableItem e in purchasedItems) { Console.WriteLine(e.Consume()); } purchasedItems.Clear(); }