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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started