java.lang.Comparable<Term>
public class Term extends java.lang.Object implements java.lang.Comparable<Term>
P(x) = 2(a_1)^3(b)x^4 - (a_2)(b_4)x^2 + 7ab + b_2
2(a_1)^3(b) is a term, and 7ab + b_2 is two terms: 7ab and b_2
Constructor | Description |
---|---|
Term() |
Default constructor.
|
Term(char letter) |
Constructor sets numericalCoefficient to 1 and initializes atoms as an array of length 1.
|
Term(double constant) |
Construct a constant term.
|
Term(double numericalCoefficient,
Atom[] atoms) |
Construct a Term with a new number and an array of Atoms.
|
Term(Atom atom) |
Construct a Term that consists of one Atom.
|
Modifier and Type | Method | Description |
---|---|---|
void |
append(Atom atom) |
Inserts new Atom at the end of Term
|
int |
compareTo(Term t) |
Used for Arrays.sort.
|
boolean |
equals(Term term) |
Check equality between two Terms.
|
Atom[] |
getAtoms() |
Get the array of Atoms
|
double |
getNumericalCoefficient() |
Get the numerical coefficient.
|
Atom[] |
getTermAtoms() |
Deprecated.
use
getAtoms() ()} instead. |
double |
getTermDouble() |
Deprecated.
use
getNumericalCoefficient() ()} instead. |
boolean |
identicalTo(Term term) |
Deprecated.
use
equals(Term) instead. |
void |
insert(Atom atom) |
Places a new Atom in the array of Atoms that make up the term.
|
boolean |
isConstantTerm() |
Checks if this is a constant term, i.e.
|
boolean |
isDouble() |
Deprecated.
use
isConstantTerm() instead. |
boolean |
isLike(Term term) |
Tests to see if two terms have "like" (same letter & subscript) Atoms
|
boolean |
isZero() |
Checks to see of the double (and hence the Term) is zero.
|
boolean |
lessThan(Term term) |
Deprecated.
Use
compareTo(Term) instead. |
boolean |
like(Term term) |
Deprecated.
Use
isLike(Term) instead. |
Term |
paste(Atom atom) |
Creates a new Term with the a new Atom at the front of Term
|
Term |
place(Atom atom) |
Places a new Atom in the array of Atoms that make up the term.
|
Atom |
pop() |
Remove first Atom and return it.
|
void |
print() |
Deprecated.
use
toString() instead. |
void |
push(Atom atom) |
Inserts new Atom at the front of Term
|
void |
reduce() |
Orders Atoms and combines like Atoms in the Array of atoms.
|
void |
setAtoms(Atom[] atoms) |
Set the array of Atoms.
|
void |
setNumericalCoefficient(double numericalCoefficient) |
Set the numericalCoefficient.
|
void |
setTerm(double num,
Atom[] atoms) |
Deprecated.
use
Term(double, Atom[]) ()} instead. |
void |
setTerm(Atom[] atoms) |
Deprecated.
use
setAtoms(Atom[]) ()} instead. |
void |
setTermDouble(double num) |
Deprecated.
use
setNumericalCoefficient(double) ()} instead. |
Term |
simplify() |
Orders Atoms and combines like Atoms in the Array of atoms.
|
Term |
snip() |
Make a new Term with the first Atom removed.
|
Term |
times(double scalar) |
Multiply Term by a scalar value.
|
Term |
times(Term term) |
Multiply Term by another Term.
|
java.lang.String |
toString() |
Composes a printable string of this term.
|
public Term()
public Term(double constant)
constant
- The constant that will be the entire term.public Term(Atom atom)
atom
- This will be the first and only Atom in the atoms arraypublic Term(char letter)
letter
- The will be the letterpublic Term(double numericalCoefficient, Atom[] atoms)
numericalCoefficient
- The numericalCoefficient attributeatoms
- Atom[] attribute@Deprecated public double getTermDouble()
getNumericalCoefficient()
()} instead.public double getNumericalCoefficient()
@Deprecated public Atom[] getTermAtoms()
getAtoms()
()} instead.public Atom[] getAtoms()
@Deprecated public void setTerm(double num, Atom[] atoms)
Term(double, Atom[])
()} instead.@Deprecated public void setTermDouble(double num)
setNumericalCoefficient(double)
()} instead.@Deprecated public void setTerm(Atom[] atoms)
setAtoms(Atom[])
()} instead.public void setNumericalCoefficient(double numericalCoefficient)
numericalCoefficient
- public void setAtoms(Atom[] atoms)
atoms
- Will become the Atoms array for this Termpublic Atom pop()
public Term snip()
public Term paste(Atom atom)
atom
- public void push(Atom atom)
atom
- public void append(Atom atom)
atom
- public Term place(Atom atom)
example: place b^2 in the Term 3abd will result in 3ab^3d example: place c_1 in the Term 3abd will result in 3abc_1d
atom
- public void insert(Atom atom)
example: place b^2 in the Term 3abd will result in 3ab^3d example: place c_1 in the Term 3abd will result in 3abc_1d
atom
- public Term simplify()
Permanently alters the Term.
public void reduce()
Permanently alters the Term.
public Term times(Term term)
term
- The Term to multiply to this onepublic Term times(double scalar)
scalar
- Value to multiply this Term by@Deprecated public boolean like(Term term)
isLike(Term)
instead.term
- Term to compare "this" topublic boolean isLike(Term term)
term
- Term to compare "this" to@Deprecated public boolean lessThan(Term term)
compareTo(Term)
instead.term
- term to comparepublic boolean isZero()
@Deprecated public boolean isDouble()
isConstantTerm()
instead.public boolean isConstantTerm()
@Deprecated public boolean identicalTo(Term term)
equals(Term)
instead.@Deprecated public void print()
toString()
instead.public boolean equals(Term term)
term
- Term to checkpublic java.lang.String toString()
toString
in class java.lang.Object
public int compareTo(Term t)
compareTo
in interface java.lang.Comparable<Term>
t
- Term to compare to