public ICryptoCurrency AddCrypto(CryptoCurrency value) { if (value.Currency.Equals(Currency)) { return(new CryptoCurrency(Amount + value.Amount, Currency)); } return(new Vault(this, value)); }
protected void SetUp() { ETH12 = new CryptoCurrency(12, "ETH"); ETH14 = new CryptoCurrency(14, "ETH"); DBIX7 = new CryptoCurrency(7, "DBIX"); DBIX21 = new CryptoCurrency(21, "DBIX"); Vault1 = new Vault(ETH12, DBIX7); Vault2 = new Vault(ETH14, DBIX21); }
public override bool Equals(Object anObject) { if (IsZero) { if (anObject is ICryptoCurrency) { return(((ICryptoCurrency)anObject).IsZero); } } if (anObject is CryptoCurrency) { CryptoCurrency aCrypto = (CryptoCurrency)anObject; return(aCrypto.Currency.Equals(Currency) && Amount == aCrypto.Amount); } return(false); }
private void AppendCrypto(CryptoCurrency c) { ICryptoCurrency old = FindCrypto(c.Currency); if (old == null) { CryptoCurrencies.Add(c); return; } CryptoCurrencies.Remove(old); ICryptoCurrency sum = old.Add(c); if (sum.IsZero) { return; } CryptoCurrencies.Add(sum); }
public ICryptoCurrency AddCrypto(CryptoCurrency c) { return((new Vault(c, this)).Simplify()); }
public Vault(CryptoCurrency c1, Vault v) { AppendCrypto(c1); AppendVault(v); }
private bool Contains(CryptoCurrency c) { CryptoCurrency crypto = FindCrypto(c.Currency); return(crypto.Amount == c.Amount); }
public Vault(CryptoCurrency c1, CryptoCurrency c2) { AppendCrypto(c1); AppendCrypto(c2); }