public Wallet(Wallet oldWallet, Coin c) { P1 = oldWallet.P1; P2 = oldWallet.P2; P5 = oldWallet.P5; P10 = oldWallet.P10; P20 = oldWallet.P20; P50 = oldWallet.P50; P100 = oldWallet.P100; P200 = oldWallet.P200; AddCoin(c); }
private void AddCashMoney(WalletBank walletBank, Wallet wallet) { int restValue = wallet.GetRestValue(); if (restValue == P1) walletBank.Add(new Wallet(wallet, Wallet.Coin.P1)); else if (restValue == P2) walletBank.Add(new Wallet(wallet, Wallet.Coin.P2)); else if (restValue == P5) walletBank.Add(new Wallet(wallet, Wallet.Coin.P5)); else if (restValue == P10) walletBank.Add(new Wallet(wallet, Wallet.Coin.P10)); else if (restValue == P20) walletBank.Add(new Wallet(wallet, Wallet.Coin.P20)); else if (restValue == P50) walletBank.Add(new Wallet(wallet, Wallet.Coin.P50)); else if (restValue == P100) walletBank.Add(new Wallet(wallet, Wallet.Coin.P100)); else if (restValue == P200) walletBank.Add(new Wallet(wallet, Wallet.Coin.P200)); if (restValue > P100 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P100)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P100)); if (restValue > P50 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P50)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P50)); if (restValue > P20 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P20)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P20)); if (restValue > P10 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P10)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P10)); if (restValue > P5 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P5)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P5)); if (restValue > P2 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P2)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P2)); if (restValue > P1 && wallet.HasNoLowerCoinsThan(Wallet.Coin.P1)) AddCashMoney(walletBank, new Wallet(wallet, Wallet.Coin.P1)); }
public void Add(Wallet wallet) { Console.Write("\rCount: {0}", walletBank.Count); foreach (Wallet w in walletBank) { if (w.IsTheSame(wallet)) return; } walletBank.Add(wallet); }
public bool IsTheSame(Wallet otherWallet) { return (P1 == otherWallet.P1 && P2 == otherWallet.P2 && P5 == otherWallet.P5 && P10 == otherWallet.P10 && P20 == otherWallet.P20 && P50 == otherWallet.P50 && P100 == otherWallet.P100 && P200 == otherWallet.P200); }