Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.70 KB | None | 0 0
  1. public boolean equals(Object other) {
  2.         if (other == Polynom.NaP || this == Polynom.NaP ){
  3.             return false;
  4.         }
  5.        
  6.         boolean eq = false;
  7.         if (other instanceof Polynom){ // hier könnte man auch this.getClass() == other.getClass()
  8.             if ((other) != null && this != null){
  9.                 if (((MapPolynom)other).degree() == this.degree()){
  10.                     int i = (int)this.degree();
  11.                     while (i>=0){
  12.                         if ( this.coeff(i) == ((MapPolynom)other).coeff(i)){
  13.                             eq = true;
  14.                             i--;
  15.                         }else{
  16.                             eq = false;
  17.                             break;
  18.                         }
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.         return eq;
  24.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement