Example #1
0
 public Procent(MoneyView numerator, MoneyView denominator, bool showMessageAboutOperationFails = true) : base(0f)
 {
     if (denominator.isZero())
     {
         if (showMessageAboutOperationFails)
         {
             Debug.Log("Division by zero in Percent.makeProcent(int)");
         }
         Set(Max999);
     }
     else
     {
         Set((float)(numerator.Get() / denominator.Get()), showMessageAboutOperationFails);
     }
 }
Example #2
0
 public Money Subtract(MoneyView storage, bool showMessageAboutNegativeValue = true)
 {
     if (storage.isBiggerThan(this))
     {
         if (showMessageAboutNegativeValue)
         {
             Debug.Log("Money subtract failed");
         }
         SetZero();
     }
     else
     {
         data = Get() - storage.Get();
     }
     return(this);
 }
Example #3
0
        ///////////////////Add section
        public Money Add(MoneyView storage, bool showMessageAboutNegativeValue = true)
        {
            decimal newData = data + storage.Get();

            if (newData < 0m)
            {
                if (showMessageAboutNegativeValue)
                {
                    Debug.Log("Money can't be negative");
                }
                data = 0m;
            }
            else
            {
                data = newData;
            }
            return(this);
        }