{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Project 2 - Extended Polynomial Class

# Project 2 - Extended Polynomial Class - Robert J England II...

This preview shows pages 1–4. Sign up to view the full content.

Robert J. England II COS 221 Project 2 Polynomial Class New Project done for Prof. Larry Latour Friday, October 27, 2006

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
The following is the actual code used in the program. There are two classes; one is the Polynomial class, which provides the bulk of the code; the other is the Test class, which tests the Polynomial class extensively. The main program does nothing more than create a Test object, and the constructor of that object performs all of the testing. Note to grader: The plotting is done with the SoftIntegration Graphical Library, which can be downloaded and installed at http://www.softintegration.com/products/silib/graphlib/ . // Polynomial.cpp :  // Polynomial class created by Robert J. England II // for COS 221 with Larry Latour // at the University of Maine in Orono // Friday, October 27, 2006 // #include   "stdafx.h" #include   <iostream> #include   <math.h> #include   "chplot.h" using   namespace  std; class  Polynomial { public : // Constructors Polynomial(); // POST: A polynomial equivalent to zero is created Polynomial( double  a0); // POST: A polynomial equivalent to constant a0 is created Polynomial(Polynomial & source); // POST: A new polynomial equivalent to this polynomial is // created // Clone method Polynomial clone(); // POST: A new polynomial equivalent to this polynomial is // created and returned // Modification methods void  addToCoef( double  amount,  int  k); // PRE:  k >= 0 // POST: The value amount is added to the kth coefficient of the // polynomial void  assignCoef( double  newCoefficient,  int  k); // PRE:  k >= 0 // POST: The kth coefficient of the polynomial is changed to the // value newCoefficient void  clear(); // POST: The polynomial is set equivalent to zero void  reserve( int  newSize); // PRE:  newSize must be greater than the current degree of the // polynomial // POST: Memory is reserved for newSize coefficients for the // polynomial
// Accessor methods double  coefficient( int  k); // PRE:  k >= 0 // POST: The kth coefficient of the polynomial is returned // If the degree of the polynomial is less than k, 0 is returned int  getDegree() { return  degree;}; // POST: The degree of the polynomial is created int  nextTerm( int  k); // POST: The next greater nonzero coefficient above k is // returned; if k is the greatest coefficient, -1 is returned; // if k is negative, function finds first nonzero coefficient // Evaluation method double  evaluate( double  x); // POST: The value of the polynomial at value x is returned // Arithmetic operators Polynomial  operator  + (Polynomial other);  // POST: The algebraic sum of the polynomials is returned Polynomial  operator  - (Polynomial other); // POST: The algebraic difference of the polynomials is returned

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 18

Project 2 - Extended Polynomial Class - Robert J England II...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online