Design an interface Polynomial that defines the following operations. 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 integer 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 of the same concrete class as this object; if it is a different class, the method may throw an IllegalArgumentException.   Now implement this interface in a class PolynomialImpl. Beyond implementing the Polynomial interface, this implementation should have the following features/obey these constraints: This class should store the polynomial using a linked list with nodes. This representation must be implemented by you (i.e. you are not allowed to use existing list or other collection classes in Java). This class should store only terms with non-zero coefficients. This class should store the polynomial terms in decreasing order of their powers. This class should have a constructor with no parameters that creates a polynomial with no terms, i.e. the polynomial 0 (how to represent this?). This class should have another constructor that takes a polynomial as a string, parses it and creates the polynomial accordingly. The string contains the polynomial, with each term separated by a space. The following examples should work with your constructor: "4x^3 +3x^1 -5" "-3x^4 -2x^5 -5 +11x^1"

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Design an interface Polynomial that defines the following operations.

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 integer 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 of the same concrete class as this object; if it is a different class, the method may throw an IllegalArgumentException.

 

Now implement this interface in a class PolynomialImpl. Beyond implementing the Polynomial interface, this implementation should have the following features/obey these constraints:

  • This class should store the polynomial using a linked list with nodes. This representation must be implemented by you (i.e. you are not allowed to use existing list or other collection classes in Java).
  • This class should store only terms with non-zero coefficients.
  • This class should store the polynomial terms in decreasing order of their powers.
  • This class should have a constructor with no parameters that creates a polynomial with no terms, i.e. the polynomial 0 (how to represent this?).
  • This class should have another constructor that takes a polynomial as a string, parses it and creates the polynomial accordingly. The string contains the polynomial, with each term separated by a space. The following examples should work with your constructor:
    • "4x^3 +3x^1 -5"
    • "-3x^4 -2x^5 -5 +11x^1"

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 7 images

Blurred answer
Knowledge Booster
Generic Type
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-engineering and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY