/*
 *Daniel Tabuenca
 *###-##-3128
 *Login: dtabuenc
 *Lab section 23
 *Assignment 1
 *Due April 28, Friday, 11:59pm, 2000
 */


#include "polyterm.h"

/*Overloaded < operator for sorting purposes.
 *We sort on the exponent.
 */
bool operator<(PolyTerm &a, PolyTerm &b)
	{
	return (a.exp>b.exp)? true:false;
	}

/*Outputs a single term in required format*/
ostream &operator<<(ostream &out, PolyTerm &term)
{
/*Just prints the base followed by the
 *exponent in parentheses.
 */
out << term.base << "(" <<term.exp<< ")";
return out;
}

PolyTerm &operator+=(PolyTerm &a, PolyTerm &b)
	{
	if(a.exp!=b.exp)
		{
		return a;
		}
	else
		{
		a.base+=b.base;
		return a;
		}
	}


PolyTerm &operator*=(PolyTerm &a, PolyTerm &b)
	{
	a.exp+=b.exp;
	a.base*=b.base;
	return a;
	}


	

syntax highlighted by Code2HTML, v. 0.8.11