So this is my final project for my class. The idea is to use my RationalNum class (which is complete and works fine... I just didn't attach the .cpp since it was only the driver) and use it to add, sub, & multi polynomials (RationalNum being the coefficients i.e. 1/4x^3 + 1/2x^2 + 1/3x, etc.).
My over all goal is to input the amount of terms I want and then input the rational coefficients and then the exponets.... the rest will be automatically calculated from there.
I am in a sense just starting this out and my mind is completely foggy and some clarification to as what I should do next would help out a lot. I'm not looking for code, just an idea of which way to step next. Pretty much have an open discussion...
Anyway I am going to re-read vectors to see if that might give me some insight.
Here's what I have so far:
#ifndef POLYNOMIAL_H
#define POLYNOMIAL_H
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <vector>
#include "RationalNum.h"
using namespace std;
class Term
{
public:
RationalNum coeff;
int exponet;
};
class Polynomial
{
public:
static const int maxTerm = 10; //Temporary since I want to select the amount of terms.
Polynomial();
Polynomial(const Polynomial &p);
~Polynomial();
void enterTerm();
int getNumTerm() const;
int getTermExp(int) const;
int getTermCoeff(int) const;
void setCoeff(int, int);
void printAll() const;
Polynomial operator+(const Polynomial& );
//Polynomial operator-(const Polynomial& );
//Polynomial operator*(const Polynomial& );
//Polynomial operator+=(const Polynomial& );
//Polynomial operator-=(const Polynomial& );
//Polynomial operator8=(const Polynomial& );
Polynomial operator+(const Term& addend) const;//added just for refrence below
private:
int numTerm;
int exponet[maxTerm];
int coeff[maxTerm];
};
Polynomial::Polynomial()
{
for(int t = 0; t < maxTerm; t++)
{
coeff[t] = 0;
exponet[t] = 0;
}
numTerm = 0;
}
Polynomial Polynomial::operator+(const Polynomial &rhs) //This is what is stated in the project instruction sheet
{
Polynomial Polynomial_LHS;
Polynomial result = *this;
vector<Term>::const_iterator PolyIter;
for(PolyIter = addend.Term.begin(); PolyIter != addend.Term.end(); PolyIter++)
{
//the loop for adding terms
//result +=*PolyIter;
}
return result;
}
Polynomial Polynomial::operator+(const Term& addend) const //This is what is stated in the project instruction sheet
{
//empty for time being
}
#endif
Oddly enough the Rational Number's part of this project was rather easy, this Polynomial part is where I stumble...
[My rational numbers class is attached below]
Thanks for the help in advance!