@Test public void testDivide () { assertEquals ("0,25", divide (1, 4)); assertEquals ("-0,25", divide (1, -4)); assertEquals ("-0,25", divide (-1, 4)); assertEquals ("0,25", divide (-1, -4)); assertEquals ("2", divide (6, 3)); assertEquals ("-2", divide (6, -3)); assertEquals ("-2", divide (-6, 3)); assertEquals ("2", divide (-6, -3)); assertEquals ("2", mOneValue.divide (mRealHalfValue).toString ()); try { mZeroValue.divide (new BooleanValue (true)); fail ("no exception"); } catch (ExecutionException ee) { } }
@Override Value divide (Value v) { if (v instanceof IntegerValue) { int integerValueOfV = v.toIntegerValue ().intValue (); if (intValue () % integerValueOfV == 0) { return new IntegerValue (intValue () / integerValueOfV); } } else if (!(v instanceof RealValue)) { throw newOperandException ("/"); } return toRealValue ().divide (v); }
IntegerValue extends Value { @Override Value divide (Value v) { if (v instanceof IntegerValue) { int integerValueOfV = v.toIntegerValue ().intValue (); if (intValue () % integerValueOfV == 0) { return new IntegerValue (intValue () / integerValueOfV); } } else if (!(v instanceof RealValue)) { throw newOperandException ("/"); } return toRealValue ().divide (v); } }
IntegerValue extends Value { @Override Value divide (Value v) { if (v instanceof IntegerValue) { int integerValueOfV = v.toIntegerValue ().intValue (); if (intValue () % integerValueOfV == 0) { return new IntegerValue (intValue () / integerValueOfV); } } else if (!(v instanceof RealValue)) { throw newOperandException ("/"); } return toRealValue ().divide (v); } IntegerValue(int value);   IntegerValue(String value); }
IntegerValue extends Value { @Override Value divide (Value v) { if (v instanceof IntegerValue) { int integerValueOfV = v.toIntegerValue ().intValue (); if (intValue () % integerValueOfV == 0) { return new IntegerValue (intValue () / integerValueOfV); } } else if (!(v instanceof RealValue)) { throw newOperandException ("/"); } return toRealValue ().divide (v); } IntegerValue(int value);   IntegerValue(String value); @Override String toString(); }
IntegerValue extends Value { @Override Value divide (Value v) { if (v instanceof IntegerValue) { int integerValueOfV = v.toIntegerValue ().intValue (); if (intValue () % integerValueOfV == 0) { return new IntegerValue (intValue () / integerValueOfV); } } else if (!(v instanceof RealValue)) { throw newOperandException ("/"); } return toRealValue ().divide (v); } IntegerValue(int value);   IntegerValue(String value); @Override String toString();  }