I am making a programming project that implements terms for polynomials. For example, if I put "7x^3+4x^2", then the class has an inner array list that stores "7x^3" and "4x^2". However, I need to implement a method .equals that I don't know how to implement very well. here is the method:
@Override public boolean equals(Polynomial P) { return true; }
It has as a parameter another Polynomial P. However, the class does not include a method get() or getTerm(), so I can't do the following:
@Override public boolean equals(Polynomial P) { int counter = -1; for(int i = 0; i <= this.terms.size() - 1; i++) { if(!(this.get(i).equals(P.get(i)))) { counter = 1; break; } } return couter == -1; }
I think I am supposed to do it with a for each loop. Can anyone help me and give me a hint of how it should be done?