Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The JUnit Test Class Your project should include a unit test class that provides an appropriate set of tests for each method in class Polynomial.

The JUnit Test Class

Your project should include a unit test class that provides an appropriate set of tests for each method in class Polynomial. The number of tests performed is not as important as how they are chosen. Be sure to include tests for general good cases, special cases, and bad cases. Thinking in advance about the full range of possible parameter values and situations will help you do a solid implementation. You may use JUnit3 or JUnit 4 syntax.

Methods Descriptions
Polynomial(String s) Construct a Polynomial based on a string which contains a series of numbers separated by whitespace. The numbers are always in pairs: coefficient followed by exponent. For example, this statement should create the polynomial illustrated in the example above:

Polynomial p = new Polynomial( "4 5 3 2 -5 0" );

This would also be a legal statement:

Polynomial p = new Polynomial( "4.8 5 -3.5 2 1.5 0" );

Polynomial(Polynomial p) Construct a Polynomial that is a duplicate (a deep copy) of the one provided without modifying p.
int terms( ) Returns the number of terms in this Polynomial.
void addTerm(double coef, int exp) Add a new term to this Polynomial if there is not already a term with the specified exponent. If a term with the specified exponent already exists, update its coefficient by summing it with the new one.
double deleteTerm(int exp) If a term with the specified exponent exists in this Polynomial, delete that term and return its coefficient; otherwise return 0.0.
double getCoefficient(int exp) Return the coefficient for the specified exponent; return 0.0 if no such term.
double evaluate(double x) Return the value of this Polynomial for the given value for the variable x.
boolean equals(Object o) Override the equals method in an appropriate way.
Polynomial derivative( ) Return the first derivative of this Polynomial. If you are not familiar with finding the derivative, you can read about it here (Links to an external site.)Links to an external site..
String toString( ) See instructions below for the string formatting requirements.
String description( ) See instructions below for the string formatting requirements.
static Polynomial sum( Polynomial a, Polynomial b) Returns a new Polynomial that represents the sum of two Polynomials (a + b) without modifying a or b.
static Polynomial product( Polynomial a, Polynomial b) Returns a new Polynomial that represents the product of two Polynomials (a * b) without modifying a or b.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Driven Web Sites

Authors: Mike Morrison, Joline Morrison

1st Edition

061901556X, 978-0619015565

More Books

Students also viewed these Databases questions