public static CurrencyBase operator +(CurrencyBase x, CurrencyBase y) { if (x.IsVariable || y.IsVariable) throw new ArithmeticException("Cannot add variable Currency!"); CurrencyBase cb = new CurrencyBase(x.Value); cb.Value += y.Value; if (cb.Value < 0) cb.Value = 0; return cb; }
public static CurrencyBase operator +(CurrencyBase x, CurrencyBase y) { if (x.IsVariable || y.IsVariable) { throw new ArithmeticException("Cannot add variable Currency!"); } CurrencyBase cb = new CurrencyBase(x.Value); cb.Value += y.Value; if (cb.Value < 0) { cb.Value = 0; } return(cb); }
public int CompareTo(CurrencyBase other) { // Check for null if (ReferenceEquals(other, null)) { return(-1); } // Check for same reference if (ReferenceEquals(this, other)) { return(0); } if (this.IsVariable != other.IsVariable) { return(this.IsVariable.CompareTo(other.IsVariable)); } return(this.Value.CompareTo(other.Value)); }
public int CompareTo(CurrencyBase other) { // Check for null if (ReferenceEquals(other, null)) return -1; // Check for same reference if (ReferenceEquals(this, other)) return 0; if (this.IsVariable != other.IsVariable) return this.IsVariable.CompareTo(other.IsVariable); return this.Value.CompareTo(other.Value); }