コード例 #1
0
ファイル: Problem031.cs プロジェクト: basterbogt/Euler
        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));
        }
コード例 #2
0
ファイル: Problem031.cs プロジェクト: basterbogt/Euler
 public override void Calculate()
 {
     WalletBank walletBank = new WalletBank();
     AddCashMoney(walletBank, new Wallet());
 }