private void StartingChange() { for (int i = 0; i < 20; i++) { Quarter quarter = new Quarter(); coins.Add(quarter); } for (int i = 0; i < 10; i++) { Dime dime = new Dime(); coins.Add(dime); } for (int i = 0; i < 20; i++) { Nickle nickle = new Nickle(); coins.Add(nickle); } for (int i = 0; i < 50; i++) { Penny penny = new Penny(); coins.Add(penny); } }
void AddCoins() { // member method for (int i = 0; i < 6; i++) { Quarter quarter = new Quarter(); coin.Add(quarter); } for (int i = 0; i < 20; i++) { Dime dime = new Dime(); coin.Add(dime); } for (int i = 0; i < 20; i++) { Nickel nickel = new Nickel(); coin.Add(nickel); } for (int i = 0; i < 50; i++) { Penny penny = new Penny(); coin.Add(penny); } }
public void StartingRegister(int quarters, int dimes, int nickels, int pennies) { for (int i = 0; i < quarters; i++) { Quarter quarter = new Quarter(); register.Add(quarter);; } for (int i = 0; i < dimes; i++) { Dime dime = new Dime(); register.Add(dime); } for (int i = 0; i < nickels; i++) { Nickel nickel = new Nickel(); register.Add(nickel); } for (int i = 0; i < pennies; i++) { Penny penny = new Penny(); register.Add(penny); } }
//Memeber methods public void CashInWallet() { for (int i = 0; i < 12; i++) { Quarter quarter = new Quarter(); coins.Add(quarter); } for (int i = 0; i < 10; i++) { Dime dime = new Dime(); coins.Add(dime); } for (int i = 0; i < 15; i++) { Nickle nickle = new Nickle(); coins.Add(nickle); } for (int i = 0; i < 25; i++) { Penny penny = new Penny(); coins.Add(penny); } }
//Member Methods (Can Do) //A method to fill the sodamachines register with coin objects. public void FillRegister() { for (int i = 0; i <= 20; i++) { Quarter quarter = new Quarter(); _register.Add(quarter); } for (int i = 0; i <= 10; i++) { Dime dime = new Dime(); _register.Add(dime); } for (int i = 0; i <= 20; i++) { Nickel nickel = new Nickel(); _register.Add(nickel); } for (int i = 0; i <= 50; i++) { Penny penny = new Penny(); _register.Add(penny); } }
//Constructor (Spawner) public SodaMachine() { _register = new List <Coin>(); _inventory = new List <Can>(); Quarter quarter = new Quarter(); Dime dime = new Dime(); Nickel nickle = new Nickel(); Penny penny = new Penny(); FillRegister(quarter, 20); FillRegister(dime, 10); FillRegister(nickle, 20); FillRegister(penny, 50); RootBeer rootBeer = new RootBeer(); Cola cola = new Cola(); OrangeSoda orangeSoda = new OrangeSoda(); FillInventory(rootBeer, 10); FillInventory(cola, 10); FillInventory(orangeSoda, 10); }
public void FillRegister() { for (int i = 0; i < 20; i++) { Quarter quarter = new Quarter(); register.Add(quarter); } for (int i = 0; i < 10; i++) { Dime dime = new Dime(); register.Add(dime); } for (int i = 0; i < 20; i++) { Nickle nickle = new Nickle(); register.Add(nickle); } for (int i = 0; i < 50; i++) { Penny penny = new Penny(); register.Add(penny); } }
//Constructor (Spawner) public SodaMachine() { _register = new List <Coin>(); _inventory = new List <Can>(); RootBeer rootBeer = new RootBeer(); Cola cola = new Cola(); OrangeSoda orangeSoda = new OrangeSoda(); FillInventory(20, rootBeer); FillInventory(20, cola); FillInventory(20, orangeSoda); Quarter quarter = new Quarter(); Dime dime = new Dime(); Nickel nickel = new Nickel(); Penny penny = new Penny(); FillRegister(20, quarter); FillRegister(10, dime); FillRegister(20, nickel); FillRegister(50, penny); }
public static string PickCoins() { Console.WriteLine("Select which coins you would like to use to pay: \n" + "--- ( 1 ) = Penny --- \n" + "--- ( 2 ) = Nickle --- \n" + "--- ( 3 ) = Dime --- \n" + "--- ( 4 ) = Quarter --- \n"); ConsoleKeyInfo thing = Console.ReadKey(); Coin coin; if (thing.Key == ConsoleKey.D1) { coin = new Penny("Penny"); Console.WriteLine(" You have deposited .01 cents!"); return("Penny"); } else if (thing.Key == ConsoleKey.D2) { coin = new Nickle("Nickle"); Console.WriteLine(" You have deposited .05 cents!"); return("Nickle"); } else if (thing.Key == ConsoleKey.D3) { coin = new Dime("Dime"); Console.WriteLine(" You have deposited .10 cents!"); return("Dime"); } else if (thing.Key == ConsoleKey.D4) { coin = new Quarter("Quarter"); Console.WriteLine(" You have deposited .25 cents!"); return("Quarter"); } else { Console.Clear(); return("nothing"); } }
public Wallet() { coins = new List <Coin>(); for (int i = 0; i < 12; i++) { Quarter quarter = new Quarter(); coins.Add(quarter); } for (int i = 0; i < 10; i++) { Dime dime = new Dime(); coins.Add(dime); } for (int i = 0; i < 10; i++) { Nickle nickle = new Nickle(); coins.Add(nickle); } for (int i = 0; i < 50; i++) { Penny penny = new Penny(); coins.Add(penny); } }
//Takes in a list of coin objects to add into the customers wallet. public void AddCoinsIntoWallet(List <Coin> coinsToAdd) { Quarter quarter = new Quarter(); Dime dime = new Dime(); Nickel nickel = new Nickel(); Penny penny = new Penny(); for (int i = 0; i < 10; i++) { Wallet.Coins.Add(quarter); } for (int i = 0; i < 23; i++) { Wallet.Coins.Add(dime); } for (int i = 0; i < 172; i++) { Wallet.Coins.Add(nickel); } for (int i = 0; i < 19; i++) { Wallet.Coins.Add(penny); } }
public SodaMachine() { register = new List <Coin>(); for (int index = 0; index < 20; index++) { Quarter quarter = new Quarter(); register.Add(quarter); } for (int index = 0; index < 10; index++) { Dime dime = new Dime(); register.Add(dime); } for (int index = 0; index < 20; index++) { Nickle nickle = new Nickle(); register.Add(nickle); } for (int index = 0; index < 50; index++) { Penny penny = new Penny(); register.Add(penny); } inventory = new List <Can>(); for (int index = 0; index < 20; index++) { Cola cola = new Cola(); OrangeSoda orangeSoda = new OrangeSoda(); RootBeer rootBeer = new RootBeer(); inventory.Add(cola); inventory.Add(orangeSoda); inventory.Add(rootBeer); } }
//Member Methods (Can Do) //A method to fill the sodamachines register with coin objects. public void FillRegister() { Quarter quarter = new Quarter(); Dime dime = new Dime(); Nickel nickel = new Nickel(); Penny penny = new Penny(); for (int i = 0; i < 20; i++) { _register.Add(quarter); } for (int i = 0; i < 10; i++) { _register.Add(dime); } for (int i = 0; i < 20; i++) { _register.Add(nickel); } for (int i = 0; i < 50; i++) { _register.Add(penny); } }
public static Dime Dime() { Dime dime = new Dime(); return(dime); }
public static void CoinPrompt(string currentCoin, List <Coin> coins, List <Coin> insertedCoins) { UserInterface.DisplayCoinWallet(coins); UserInterface.AskForNextCoin(currentCoin); int coinsEntered; int counter = 0; switch (currentCoin) { case "quarters": coinsEntered = UserInterface.GetIntInput(); for (int i = 0; i < coins.Count; i++) { if (counter == (coinsEntered)) { break; } if (coins[i].name == "quarter") { Quarter quarter = new Quarter(); insertedCoins.Add(quarter); coins.RemoveAt(i); counter++; i--; } } UserInterface.DisplayCoinInserted(counter, currentCoin); break; case "dimes": coinsEntered = UserInterface.GetIntInput(); for (int i = 0; i < coins.Count; i++) { if (counter == coinsEntered) { break; } if (coins[i].name == "dime") { Dime dime = new Dime(); insertedCoins.Add(dime); coins.RemoveAt(i); counter++; i--; } } UserInterface.DisplayCoinInserted(counter, currentCoin); break; case "nickels": coinsEntered = UserInterface.GetIntInput(); for (int i = 0; i < coins.Count; i++) { if (counter == coinsEntered) { break; } if (coins[i].name == "nickel") { Nickel nickel = new Nickel(); insertedCoins.Add(nickel); coins.RemoveAt(i); counter++; i--; } } UserInterface.DisplayCoinInserted(counter, currentCoin); break; case "pennies": coinsEntered = UserInterface.GetIntInput(); for (int i = 0; i < coins.Count; i++) { if (counter == coinsEntered) { break; } if (coins[i].name == "penny") { Penny penny = new Penny(); insertedCoins.Add(penny); coins.RemoveAt(i); counter++; i--; } } UserInterface.DisplayCoinInserted(counter, currentCoin); break; default: break; } }
////original //public List<Coin> SetAmountToDispense() //{ // int index = 0; // List<Coin> changeSelection = new List<Coin>(); // foreach (Coin item in customer.wallet.coins) // { // Console.WriteLine($"Choose {index} {item.name}"); // index++; // } // int coinCount = customer.wallet.coins.Count + 1; // Console.WriteLine($"Enter {coinCount} when done selecting coins"); // int choice = int.Parse(Console.ReadLine()); // while (choice != coinCount) // { // changeSelection.Add(customer.wallet.coins[choice]); // Console.WriteLine("Enter another amount"); // choice = int.Parse(Console.ReadLine()); // } // return changeSelection; //} public List <Coin> SetAmountToDispense() { bool stop = true; List <Coin> changeSelection = new List <Coin>(); Quarter quarter = new Quarter(); Dime dime = new Dime(); Nickel nickel = new Nickel(); Penny penny = new Penny(); Wallet newWallet = new Wallet(); int quarterCount = 0; int dimeCount = 0; int nickelCount = 0; int pennyCount = 0; while (stop) { Console.WriteLine($"Enter coins:"); if (newWallet.coins.Count != 0) { foreach (Coin coin in newWallet.coins) { if (coin.name == "quarter") { quarterCount++; } } if (quarterCount > 0) { Console.WriteLine($"Enter quarter"); quarterCount = 0; } foreach (Coin coin in newWallet.coins) { if (coin.name == "dime") { dimeCount++; } } if (dimeCount > 0) { Console.WriteLine($"Enter dime"); dimeCount = 0; } foreach (Coin coin in newWallet.coins) { if (coin.name == "nickel") { nickelCount++; } } if (nickelCount > 0) { Console.WriteLine($"Enter nickel"); nickelCount = 0; } foreach (Coin coin in newWallet.coins) { if (coin.name == "penny") { pennyCount++; } } if (pennyCount > 0) { Console.WriteLine($"Enter penny"); pennyCount = 0; } } Console.WriteLine($"Enter done when finished"); string userInput = Console.ReadLine(); userInput = userInput.ToLower(); switch (userInput) { case "quarter": Coin quarterCoin = newWallet.coins.Where(u => u.name == "quarter").FirstOrDefault(); changeSelection.Add(quarter); newWallet.coins.Remove(quarterCoin); break; case "dime": Coin dimeCoin = newWallet.coins.Where(u => u.name == "dime").FirstOrDefault(); changeSelection.Add(dimeCoin); newWallet.coins.Remove(dimeCoin); break; case "nickel": Coin nickelCoin = newWallet.coins.Where(u => u.name == "nickel").FirstOrDefault(); changeSelection.Add(nickelCoin); newWallet.coins.Remove(nickelCoin); break; case "penny": Coin pennyCoin = newWallet.coins.Where(u => u.name == "penny").FirstOrDefault(); changeSelection.Add(pennyCoin); newWallet.coins.Remove(pennyCoin); break; case "done": stop = false; break; default: Console.WriteLine($"Please enter a valid coinage"); break; } } return(changeSelection); }
public void GiveChange(double amount) { double quarterValue = 0; double remainder = 0; double dimeValue = 0; int dimeValueToInt = 0; int quarterValueToInt = 0; double nickelValue = 0; int nickelValueToInt = 0; double pennyValue = 0; int pennyValueToInt = 0; if (amount > .25 || amount < .25) { if (amount < .25) { remainder = amount; } else { //quarterValue = amount / .25; //quarterValueToInt = (int)quarterValue; quarterValueToInt = GetNumberOfCoins(amount, .25); //remainder = amount % .25; //remainder = Math.Round(remainder, 2); remainder = GetRemainder(amount, .25); //Add quarters to wallet Quarter quarter = new Quarter(); AddChangeToWallet(quarter, quarterValueToInt); } } if (remainder > .10) { //dimeValue = remainder / .10; //dimeValueToInt = (int)dimeValue; dimeValueToInt = GetNumberOfCoins(remainder, .10); //remainder = remainder % .10; //remainder = Math.Round(remainder, 2); remainder = GetRemainder(remainder, .10); //Add dimes to wallet Dime dime = new Dime(); AddChangeToWallet(dime, dimeValueToInt); } if (remainder > .05) { //nickelValue = remainder / .05; //nickelValueToInt = (int)nickelValue; nickelValueToInt = GetNumberOfCoins(remainder, .05); //remainder = remainder % .05; //remainder = Math.Round(remainder, 2); remainder = GetRemainder(remainder, .05); //Add nickels to wllet Nickel nickel = new Nickel(); AddChangeToWallet(nickel, nickelValueToInt); } if (remainder >= .01) { //pennyValue = remainder / .01; //pennyValueToInt = (int)pennyValue; pennyValueToInt = GetNumberOfCoins(remainder, .01); //remainder = remainder % .01; //remainder = Math.Round(remainder, 2); remainder = GetRemainder(remainder, .01); //Add pennies to wllet Penny penny = new Penny(); AddChangeToWallet(penny, pennyValueToInt); } }
public void AddDimeToSodaMachine() { Dime dime = new Dime(); register.Add(dime); }
public void AddDimeToSelectedCoins() { Dime dime = new Dime(); selectedCoins.Add(dime); }
public void StockChangeInMachine() { for (int i = 0; i <= 10; i++) { Dime dime = new Dime(); coins.Add(dime); } for (int i = 0; i <= 20; i++) { Quarter quarter = new Quarter(); coins.Add(quarter); } for (int i = 0; i <= 20; i++) { Nickel nickel = new Nickel(); coins.Add(nickel); } for (int i = 0; i <= 50; i++) { Penny penny = new Penny(); coins.Add(penny); } // these errors are new that i dont under stand at first it says can //priceGrape was to restricted so i changed the variable from inventory to public if (coins < canPriceGrape) // now thw whole thing is a error whould like clarity {// wasnt sure how to return money Console.WriteLine("Did not put in enough money"); Console.ReadLine(); } if (coins < canPriceOrange) { Console.WriteLine("Did not put in enough money"); Console.ReadLine(); } if (coins < canPriceLemon) { Console.WriteLine("Did not put in enough money"); Console.ReadLine(); } if (coins = canPriceGrape) { Console.WriteLine("You have just purchased a Grape soda "); Console.ReadLine(); } if (coins = canPriceOrange) { Console.WriteLine("You have just purchased a Orange soda "); Console.ReadLine(); } if (coins = canPriceLemon) { Console.WriteLine("You have just purchased a Lemon soda "); Console.ReadLine(); } }
public void AddDimeToWallet() { Dime dime = new Dime(); coins.Add(dime); }