• API
• FAQ
• Tools
• Archive
daily pastebin goal
27%
SHARE
TWEET

# Untitled

a guest Jan 21st, 2019 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. public class Poly {
2.    //OVERVIEW: Polys are immutable polynomials with integer coefficients.
3.   //A typical Poly is c0 + c1x + . . .
4.   // constructors
5.    public Poly ( )
6.       //EFFECTS: Initializes this to be the zero polynomial.
7.
8.    public Poly (int c, int n) throws NegativeExponentException
9.       //EFFECTS: If n < 0 throws NegativeExponentException else
10.      //initializes this to be the Poly cxn.
11.      // methods
12.    public int degree ( )
13.       //EFFECTS: Returns the degree of this, i.e., the largest exponent
14.     //with a non-zero coefficient. Returns 0 if this is the zero Poly.
15.
16.    public int coeff (int d)
17.       //EFFECTS: Returns the coefficient of the term of this whose exponent is d.
18.
19.    public Poly add (Poly q) throws NullPointerException
20.       //EFFECTS: If q is null throws NullPointerException else
21.      //returns the Poly this + q.
22.
23.    public Poly mul (Poly q) throws NullPointerException
24.       //EFFECTS: If q is null throws NullPointerException else
25.      //returns the Poly this * q.
26.
27.    public Poly sub (Poly q) throws NullPointerException
28.       //EFFECTS: If q is null throws NullPointerException else
29.      //returns the Poly this - q.
30.
31.    public Poly minus ( )
32.       //EFFECTS: Returns the Poly - this.
33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

Top