COMP 2100 Lab Exercise 5: Make a Difference
(10 points)
Turn in before the next lab session.
For this exercise, you will extend the Polynomial class (Project 2) with a class having one method.
public static Polynomial difference(Polynomial a, Polynomial b) throws IllegalArgumentException Produces a new Polynomial which is the difference between the two argument polynomials. In other words, it is the result of subtracting the second polynomial from the first one. Preconditions: a != null && b != null Parameters:
Returns:
Throws:
|
This method provides the capability of subtracting one polynomial from another. For example if a is 2x2 - 4 and b is x2 + 3x - 3, then subtracting b from a yields x2 - 3x - 1
To keep this exercise independent from Project 2, you will do the following:
Make life easier for yourself by defining subtraction in terms of existing Polynomial operations.
Points | Description |
---|---|
8 | Produces correct results |
2 | Clever design will be rewarded. |