#ifndef POLYNOMIAL_H #define POLYNOMIAL_H #include #include using namespace std; //The Polynomial class represents a polynomial equation. //Author: Robert Russell //Date: April 11, 2009 class Polynomial { public: //Constructor: Creates an instance of Polynomial. This instance //of Polynomial does not contain an equation. Polynomial(); //Constructor: Creates an instance of Polynomial. //In: A string containing the polynomial equation. //Out: None Polynomial(string equation); //Evaluates the polynomial based on the given value for the variable. //In: The value of the variable for the polynomail. //Out: The value of the polynomial. double eval(int variable); //Returns the vector containing information about the polynomial equation. //In: None //Out: The vector containing information about the polynomial equation. vector >getPolynomial(); //Adds two polynomial equations together. //In: The given polynomial to add with this polynomial. //Out: A new instance of Polynomial that is the result of //adding both instances of Polynomial. Polynomial operator+(Polynomial &secondPolynomial); //Takes the difference of two polynomial equations. //In: The given polynomial to subtract from this polynomial. //Out: A new instance of Polynomial that is the result of //taking the difference of both instances of Polynomial. Polynomial operator-(Polynomial &secondPolynomial); //Multiply two polynomial equations together. //In: The given polynomial to multiply with this polynomial. //Out: A new instance of Polynomial that is the result of //multiplying both instances of Polynomial. Polynomial operator*(Polynomial &secondPolynomial); //Determine whether the given polynomial is equal to this Polynomial. //In: The given instance of Polynomial. //Out: True if both instances of Polynomial are equal, false otherwise. bool operator==(Polynomial &secondPolynomial); //Determine whether the given polynomial is unequal to this Polynomial. //In: The given instance of Polynomial. //Out: True if both instances of Polynomial are unequal, false otherwise. bool operator!=(Polynomial &secondPolynomial); friend ostream &operator<<(ostream &stream, Polynomial &polynomial); friend istream &operator>>(istream &stream, Polynomial &polynomial); private: //Constructor: Creates an instance of Polynomial. //In: A vector of pairs representing the polynomial equation. //Out: None Polynomial(vector > polynomial); //Vector of pairs representing the polynomial. vector > polynomial; }; #endif // POLYNOMIAL_H