I am creating a method to multiply 2 polynomial expressions together such that:
3x^5 * 2x^3 = 6x^8
-> Where the coefficients are multiplied and the exponents are added together.
My test case for this would look something like the following
@Test
public void times01() throws TError { assertEquals(Term.Zero, Term.Zero.times(Term.Zero)); }
I should also add that Term.Zero = (0,0)
and Term.Unit = (1,0)
So anything multiplied by Term.Zero
is Term.Zero
and anything multiplied by Term.Unit
returns itself as Term.Unit
effectively is 1.
public Term times(Term that) throws CoefficientOverflow, ExponentOverflow, NegativeExponent {
return null;
}
This is the times
method. I'm asking for some help with coding the times
method? The problem I've found is how to deal with the 3 Term objects, Term1
, Term2
and Term3
and not using an endless amount of if-statements
.