public override CalculationResult Divide(NumberResult second)
 {
     if (string.IsNullOrEmpty(this.Value))
     {
         return(new NumberResult(0));
     }
     throw new Exception("Can`t divide strings.");
 }
 public override BoolResult IsLess(NumberResult second)
 {
     if (string.IsNullOrEmpty(this.Value))
     {
         return(new BoolResult(false));
     }
     return(new BoolResult(false));
 }
Beispiel #3
0
        public override CalculationResult Divide(NumberResult second)
        {
            var secondValue = double.Parse(second.Value);

            if (secondValue == 0)
            {
                return(new NumberResult(0));
            }
            return(new NumberResult(double.Parse(this.Value) / secondValue));
        }
 public override CalculationResult Multiply(NumberResult second)
 {
     if (int.TryParse(second.Value, out var res))
     {
         return(new StringResult(string.Join("", Enumerable.Repeat(this.Value, res))));
     }
     else
     {
         throw new Exception("Cant multiply number and string.");
     }
 }
 public override CalculationResult Substract(NumberResult second)
 {
     if (string.IsNullOrEmpty(this.Value))
     {
         return(new NumberResult(0 - double.Parse(second.Value)));
     }
     if (double.TryParse(this.Value, out _))
     {
         return(new NumberResult(double.Parse(Value) - double.Parse(second.Value)));
     }
     throw new Exception("Can`t substract Strings.");
 }
 public override CalculationResult Add(NumberResult second)
 {
     return(new StringResult(this.Value + second.Value));
 }
Beispiel #7
0
 public override CalculationResult Divide(NumberResult second)
 {
     throw new Exception("Can`t divide dates.");
 }
 public abstract BoolResult IsBigger(NumberResult second);
 public abstract CalculationResult Multiply(NumberResult second);
Beispiel #10
0
 public override CalculationResult Multiply(NumberResult second)
 {
     throw new Exception("Can`t multiply dates.");
 }
Beispiel #11
0
 public override CalculationResult Substract(NumberResult second)
 {
     throw new Exception("Can`t substract Date and Number.");
 }
Beispiel #12
0
 public override CalculationResult Add(NumberResult second)
 {
     throw new Exception("Can`t add date and number");
 }
Beispiel #13
0
 public override BoolResult IsLess(NumberResult second)
 {
     return(new BoolResult(true));
 }
Beispiel #14
0
 public override BoolResult IsBigger(NumberResult second)
 {
     return(new BoolResult(false));
 }
Beispiel #15
0
 public override BoolResult IsLess(NumberResult second)
 {
     return(new BoolResult(double.Parse(this.Value) < double.Parse(second.Value)));
 }
 public abstract CalculationResult Substract(NumberResult second);
Beispiel #17
0
 public override CalculationResult Substract(NumberResult second)
 {
     return(new NumberResult(double.Parse(this.Value) - double.Parse(second.Value)));
 }
 public abstract CalculationResult Divide(NumberResult second);
Beispiel #19
0
 public override CalculationResult Multiply(NumberResult second)
 {
     return(new NumberResult(double.Parse(this.Value) * double.Parse(second.Value)));
 }
 public abstract BoolResult IsLess(NumberResult second);
Beispiel #21
0
 public override CalculationResult Add(NumberResult second)
 {
     throw new Exception("Can`t add bools.");
 }