public Polynomial add(Polynomial P2) {
		PolynomialImp result=new PolynomialImp("");
		for(Term t1:this.terms){
			boolean found=false;
			for(Term t2:P2){
				//sum if the second term is equal to the term in the first one, break
				if(t1.getExponent()==t2.getExponent()){
					found=true;
					TermImp newTerm = new TermImp(t1.getCoefficient()+t2.getCoefficient(),t1.getExponent());
					result.addTerm(newTerm);
					break;
				}
			}
			//if there is not a term with the same exponent add at the end of the polynomial
			if(!found){
				TermImp newTerm = new TermImp(t1.getCoefficient(),t1.getExponent());
				result.addTerm(newTerm);
			}
		}
		//takes care of the terms not added in the second polynomial
		for(Term t1:P2){
			boolean notFound=true;
			for(Term t2:this.terms){
				//checks if it was already added
				if(t1.getExponent()==t2.getExponent()){
					notFound=false;
				}
			}
			//add if exponent not found
			if(notFound){
				TermImp newTerm = new TermImp(t1.getCoefficient(),t1.getExponent());
				result.addTerm(newTerm);
			}
		}
		return result;
	}