Interface ArithmeticObject<T>

Type Parameters:
T - The type of the operands and returned values from operations on objects that implement this interface.

public interface ArithmeticObject<T>

This interface specifies the major arithmetic operations for objects implementing this interface. The operands and returned values are of type T, where T is the type parameter for this interface.

Author:
David Mutchler, based on work by Claude Anderson. Created Oct 9, 2005.

Method Summary
 Tabs()
          Returns a type T object whose value is the absolute value of this ArithmeticObject.
 Tadd(T other)
          Returns a type T object whose value is (this + other), that is, the result of adding the given type T object to this ArithmeticObject.
 Tdivide(T other)
          Returns a type T object whose value is (this / other), that is, the result of dividing this ArithmeticObject by the given type T object.
 Tmultiply(T other)
          Returns a type T object whose value is (this * other), that is, the result of multiplying this ArithmeticObject by the given type T object.
 Tnegate()
          Returns a type T object whose value is (- this), that is, has the same absolute value but opposite sign of this ArithmeticObject.
 Tsubtract(T other)
          Returns a type T object whose value is (this - other), that is, the result of subtracting the given type T object from this ArithmeticObject.
 

Method Detail

abs

T abs()
Returns a type T object whose value is the absolute value of this ArithmeticObject.

Returns:
A type T object whose value is the absolute value of this ArithmeticObject.

negate

T negate()
Returns a type T object whose value is (- this), that is, has the same absolute value but opposite sign of this ArithmeticObject.

Returns:
A type T object whose value is (- this), that is, has the same absolute value but opposite sign of this ArithmeticObject.

add

T add(T other)
Returns a type T object whose value is (this + other), that is, the result of adding the given type T object to this ArithmeticObject.

Parameters:
other - The type T object to add to this ArithmeticObject.
Returns:
A type T object whose value is (this + other), that is, the result of adding the given type T object to this ArithmeticObject.

subtract

T subtract(T other)
Returns a type T object whose value is (this - other), that is, the result of subtracting the given type T object from this ArithmeticObject.

Parameters:
other - The type T object to subtract from this ArithmeticObject.
Returns:
A type T object whose value is (this - other), that is, the result of subtracting the given type T object from this ArithmeticObject.

multiply

T multiply(T other)
Returns a type T object whose value is (this * other), that is, the result of multiplying this ArithmeticObject by the given type T object.

Parameters:
other - The type T object by which this ArithmeticObject is to be multiplied.
Returns:
A type T object whose value is (this * other), that is, the result of multiplying this ArithmeticObject by the given type T object.

divide

T divide(T other)
         throws java.lang.ArithmeticException
Returns a type T object whose value is (this / other), that is, the result of dividing this ArithmeticObject by the given type T object.

Parameters:
other - The type T object by which this ArithmeticObject is to be divided.
Returns:
A type T object whose value is (this / other), that is, the result of dividing this ArithmeticObject by the given type T object.
Throws:
java.lang.ArithmeticException - If the given divisor has zero as its value.