Esempio n. 1
0
 public ICryptoCurrency AddCrypto(CryptoCurrency value)
 {
     if (value.Currency.Equals(Currency))
     {
         return(new CryptoCurrency(Amount + value.Amount, Currency));
     }
     return(new Vault(this, value));
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
 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);
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
 public ICryptoCurrency AddCrypto(CryptoCurrency c)
 {
     return((new Vault(c, this)).Simplify());
 }
Esempio n. 6
0
 public Vault(CryptoCurrency c1, Vault v)
 {
     AppendCrypto(c1);
     AppendVault(v);
 }
Esempio n. 7
0
        private bool Contains(CryptoCurrency c)
        {
            CryptoCurrency crypto = FindCrypto(c.Currency);

            return(crypto.Amount == c.Amount);
        }
Esempio n. 8
0
 public Vault(CryptoCurrency c1, CryptoCurrency c2)
 {
     AppendCrypto(c1);
     AppendCrypto(c2);
 }