Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Title: Polynomials. Summary: Using interfaces to hide concrete implementations of an interface using Java 8+ new features. Question: Write a class to store polynomials of
Title: Polynomials. Summary: Using interfaces to hide concrete implementations of an interface using Java 8+ new features. Question: Write a class to store polynomials of arbitrary order, and a program that adds together two polynomials to create a third polynomial object. In this task you will create an abstract data type (ADT) to represent a mathematical polynomial. The ADT is called Poly and should comprised from an interface Poly and an implementation class QPoly. The interface has two methods, one to create QPoly objects of the type Poly and another to add to polynomial objects of type Poly(called addPoly). A quadratic polynomial has three terms at most ax + bx' + cx where a, b, and c can be any integer values. To store a polynomial, which will be used to represent a polynomial, all what is needed is to maintain an array of the coefficients (array = [c, b, a]). In this task, 1. Write a Poly ADT to represent a quadratic polynomial. 2. The interface should offer two services, a. make(int [] array) that returns a Poly object. b. addPoly(Poly another) that takes another Poly object, adds is to itself and returns a new Poly object. 3. Implement these services in QPoly class and add a toString() method that returns a string representation of the polynomial. 4. Write a TestPoly class with main method to test adding two polynomial objects. a. DO NOT use the new keyword in creating instances of QPoly objects. b. Only use Poly type. c. Use the following test case to demo your ADT implementation javac Test Poly java Test Poly pl (x) = 5x^2 + 3x 1x^0 p2(x) = x^2 5x + 10X0 p3 (x) pl + p2 = 6x^2 2x + 9x^0
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