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

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