Opus5
Class Term

java.lang.Object
  |
  +--Opus5.AbstractObject
        |
        +--Opus5.Term
All Implemented Interfaces:
Comparable

public class Term
extends AbstractObject

A term in a polynomial.

Version:
$Id: Term.java,v 3.2 1998/07/28 02:35:50 brpreiss Exp $
Author:
Bruno R. Preiss, P.Eng.
See Also:
Polynomial

Field Summary
protected  double coefficient
          The coefficient of this term.
protected  int exponent
          The exponent of this term.
 
Fields inherited from interface Opus5.Comparable
copyright
 
Constructor Summary
Term(double coefficient, int exponent)
          Constructs a Term with the specified coefficient and exponent.
Term(Term term)
          Constructs a Term with the same value as the specified term.
 
Method Summary
protected  int compareTo(Comparable object)
          Compares this term with the specified comparable object.
 void differentiate()
          Differentiates this term.
 double getCoefficient()
          Returns the coefficient of this term.
 int getExponent()
          Returns the exponent of this term.
 java.lang.String toString()
          Returns a string representation of this term.
 
Methods inherited from class Opus5.AbstractObject
compare, equals, isEQ, isGE, isGT, isLE, isLT, isNE
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

coefficient

protected double coefficient
The coefficient of this term.

exponent

protected int exponent
The exponent of this term.
Constructor Detail

Term

public Term(double coefficient,
            int exponent)
Constructs a Term with the specified coefficient and exponent.
Parameters:
coefficient - The desired coefficient.
exponent - The desired exponent.

Term

public Term(Term term)
Constructs a Term with the same value as the specified term.
Parameters:
term - The term to copy.
Method Detail

compareTo

protected int compareTo(Comparable object)
Compares this term with the specified comparable object. The specified comparable object is assumed to be a Term instance. If the exponents of the terms differ, then the term with the smaller exponent is less than the term with the larger coefficient. If the exponents are equal but the coefficients differ, then the term with the smaller coefficient is less than the term with the larger coefficient. Otherwise, the terms are considered to be equal.
Overrides:
compareTo in class AbstractObject
Parameters:
object - The object with which this term is compared.
Returns:
a number less than zero if this term is less than the specified term; a number greater than zero if this term is greater than the specified term; zero if the two terms are equal.

differentiate

public void differentiate()
Differentiates this term.

getCoefficient

public double getCoefficient()
Returns the coefficient of this term.
Returns:
The coefficient of this term.

getExponent

public int getExponent()
Returns the exponent of this term.
Returns:
The exponent of this term.

toString

public java.lang.String toString()
Returns a string representation of this term.
Overrides:
toString in class java.lang.Object
Returns:
A string representation of this term.