Question: In Java: Design an interface Polynomial that defines a recursive function. DO NOT USE ANY HASH FUNCTION. This is your polynomial abstract data type. Specifically

In Java:

Design an interface Polynomial that defines a recursive function. DO NOT USE ANY HASH FUNCTION. This is your polynomial abstract data type. Specifically this interface should have the following method signatures:

  • A method addTerm that takes a coefficient and a power (both integral numbers) and adds the resulting term to the polynomial. (This will enable you to build a polynomial term-by-term.) It should throw an IllegalArgumentException if a negative power is passed to it.

  • A method removeTerm that takes a power and removes any and all terms in the polynomial with that power.

  • A method getDegree that returns the degree of this polynomial.

  • A method getCoefficient that takes a power and returns the coefficient for the term with that power.

  • A method evaluate that takes a double-precision decimal number and returns a double-precision result.

  • A method add that takes another Polynomial object and returns the polynomial obtained by adding the two polynomials. Any implementation should ensure that this method does not mutate either polynomial. The implementation may assume that the given Polynomial is the of the same concrete class as this object; if it is a different class, the method may throw an IllegalArgumentException.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!