public void TakeMoney(BatchCoins coinBatch) { bool check = false; foreach (Coins coin in coinBatch) { if (CheckCoins(coin)) { check = true; } else { check = false; break; } } foreach (Coins coin in coinBatch) { if (check == true) { if (coinDesk.ContainsKey(coin.CoinAmmount)) { coinDesk[coin.CoinAmmount] += 1; } else { coinDesk.Add(coin.CoinAmmount, 1); } } } }