public static Wallet operator +(Wallet wallet1, Wallet wallet2) { Wallet resultwallet = new Wallet(wallet1.coins); foreach (var coin in wallet2.coins) { var c = resultwallet.CoinByValue(coin.value); if (c != null) { c.count += coin.count; } else { resultwallet.coins.Add(coin); } } return resultwallet; }
public Wallet Substruct(Wallet p) { Wallet result = new Wallet(); foreach (var coin in this.coins) { CoinSet c = p.CoinByValue(coin.value); if ( c != null ) coin.count -= c.count; } return result; }