Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Chapter 5 Data Abstractie Figure 5.4 Specification of the Poly data abstraction public class Polyt // OVERVIEW: Polys are immutable polynomials with integer coefficients. VA

image text in transcribedimage text in transcribed

Chapter 5 Data Abstractie Figure 5.4 Specification of the Poly data abstraction public class Polyt // OVERVIEW: Polys are immutable polynomials with integer coefficients. VA A typical Poly is co + x + W constructors public Poly EFFECTS: Initializes this to be the zero polynomial public Poly (inte, int n) throws NegativeExponentException EFFECTS. If no throws NegativeExponentException else Initializes this to be the Poly oth W methods public int degree // EFFECTS: Returns the degree of this, ie, the largest exponent with a non-zero coefficient. Return of this is the zero Poly public int coeff (int d) 7/ EFFECTS Returns the coefficient of the term of this whose exponent is d. public Poly add (Poly q) throws NullPointerException // EFFECTS: Ifqis null throws NullPointerException else YA returns the Poly this +9 public Poly mul (Poly 9) throws NullPointerException // EFFECTS: If q is null throws NullPointerException else W returns the Poly this 1 public Poly sub (Poly q) throws NullPointerException // EFFECTS: If q is null throws NullPointerException else // returns the Poly this 9. public Poly minus () // EFFECTS: Returns the Poly - this. c 12 5.3 Suppose Polys (Figure 5.4) were implemented with the zero Poly represented by the empty array. Give the rep invariant and abstraction function for this implementation, and implement repok and toString. Chapter 5 Data Abstractil Figure 5.4 Specification of the Poly data abstraction public class Poly // OVERVIEW Polys are imutable polynomials with integer coefficients A typical Poly s co + x + // constructors pubiac Poly WERTOTS: Initializes this to be the ser polynomial puble Poly (int int n) throws Negative ExponentException EFECTS Ino throws NegativeExponentException else Initializes this to be the Polyer methods publ int degree EFFECTS: Returns the degree of the the largest exponent toith a non-cer coefficient Returns of this is the zene Poly public int coort int d) EFFECTS. Return the coefficient of the term of this whose exponent is d. public Poly add (Poly q) throws SullPointerException Y EFFECTS: 1jqis null throws NullPointerException else returns the Paly thin +9 public Poly mal (Poly ) throws NullPointerException W/ EFFECTS If qs multituus NullPointerException ese V returns the Polythe public Poly sub (Poly ) throws NullPointerException // EFFECTS://qis wall throws NullPointerException else I returns the Poly this -9. public Poly minus // KFFECTS: Returns the Poly - this 3

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

More Books

Students also viewed these Databases questions

Question

4. Identify the challenges facing todays organizations

Answered: 1 week ago