/*
File name: Poly.h
Author: Bo Bayles
E-mail address: bmb3h6@umr.edu
Description: This header file for the Poly class.
*/

#include <iostream>
using namespace std;

const int iMAXSIZE = 6;
//iMAXSIZE indicates the maximum possible degree for a polynomial.

class Poly
{
  private:
    float pos[iMAXSIZE];
    //Represent the polynomial as an array of float coefficients. The
    //  degree is indicated by the array position.
  
  public:
    Poly();
    //Default constructor
    //Pre: 
    //Post: An object of class Poly is constructed.
        
    Poly(const float fCoeff, const int iDeg);
    //Coefficient, degree constructor
    //Pre: fCoeff is a positive or negative floating point number. iDeg
    //  is a positive integer no more than iMAXSIZE.
    //Post: An object is constructed with fCoeff in the array position
    // indicated by iDeg.

    Poly(const float fCoeff);
    //0 position constructor
    //Pre: fCoeff is a positive or negative floating point number. iDeg
    //  is a positive integer no more than iMAXSIZE.
    //Post: An object is constructed with fCoeff in the array position 0.

    Poly(const Poly& p);
    //Copy constructor
    //Pre: p is an object of class Poly passed to a function by value.
    //Post: The values of the pos array are copied into the new object.
    
    ~Poly();
    //Destructor
    //Pre: An object of class Poly exists.
    //Post: An object of class Poly is destructed.

    friend Poly operator+(Poly p, const Poly q);
    //+ Operator
    //Pre: p and q are two objects of type Poly passed by value.
    //Post: A Poly object with the result of p + q is returned to the
    //  calling function.
    
    Poly& operator+=(const Poly& p);
    //+= Operator
    //Pre: p is an object of type Poly passed by value.
    //Post: The calling Poly object with the result of p+= q is returned
    //  to the calling function.
        
    friend Poly operator-(Poly p, const Poly q);
    //-= Operator
    //Pre: p and q are two objects of type Poly passed by value.
    //Post: A Poly object with the result of p - q is returned to the
    //  calling function.
        
    Poly& operator-=(const Poly& p);
    //-= Operator
    //Pre: p is an object of type Poly passed by value.
    //Post: The calling Poly object with the result of p-= q is returned
    //  to the calling function.

    friend Poly operator*(Poly p, const Poly q);
    //* Operator
    //Pre: p is an object of type Poly passed by value. fMult is a float
    //  indicating the value by which to multiply p.
    //Post: A Poly object with the result of p * fMult is returned to the
    //  calling function, where fMult is msultiplied by each coefficient
    //  in p's pos array.
    
    Poly& operator*=(const float fMult);
    //*= Operator
    //Pre: fMult is a float indicating the value by which to multiply p.
    //Post: The calling Poly object with the result of fMult * each
    //  coefficient in its pos array is returned to the calling function.

    friend ostream& operator<<(ostream &out, Poly p);
    //<< definition for objects of class Poly
    //Pre: out is an output stream passed by reference and p is an object
    //  of type poly that is to be displayed.
    //Post:  Each element of p's pos array is outputted with an x to the
    //  degree indicated by the array index, and the output stream is
    //  returned to the calling function.

    float operator()(const float fValue);
    //() Operator
    //Pre: fValue is a float indicating the value at which to evaluate
    //  the calling polynomial object.
    //Post: A float indicating the value of the polynomial object at
    //  fValue is returned to the calling function.

    Poly operator-();
    //- Operator
    //Pre: The calling Poly object is unmodified.
    //Post: Each position in the calling object's pos array is negated
    //  and the resultant polynomial is returned to the calling function.
        
    Poly operator~();
    //~ Operator
    //Pre: The calling Poly object is unmodified.
    //Post: The highest non-zero position of the calling object's pos
    //  array is changed to zero and returned to the calling function.
        
    operator bool() const;
    //Automatic bool conversion constructor
    //Pre: The calling Poly object is unmodified.
    //Post: If all elements in the calling object's pos array are 0, false
    //  is returned. Else true is returned.
    
    bool emptyBefore(const int iDeg);
    //Empty before function
    //Pre: iDeg is a valid positive integer less than iMAXSIZE - 1 that
    //  represents the degree of the polynomial passed.
    //Post: If the polynomial's pos array contains 0's in every position
    //  before the one indicated by iDeg, return true. Else return false.
};

