Advertisement
rsvaco

cap CCDFG4ai ppt

Oct 26th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. /**
  2.  * Compara si una jugada (this) gana a otra jugada.
  3.  * En concreto, devuelve:
  4.  *    0  si una (this) y otra empatan;
  5.  *    -1 si una (this) gana a la otra;
  6.  *    +1 si una (this) pierde con la otra.
  7.  * @param otra Jugada
  8.  * @return int
  9.  */
  10. public int ganaA(Jugada otro) {
  11.     int res = 0;
  12.     int operacion = this.getEleccion() - otro.getEleccion();
  13.     int modulo = (int) Math.abs(operacion);
  14.     int signo = (int) Math.signum(operacion);
  15.     if(operacion != 0) {
  16.         if(signo == 1)/*+*/ {
  17.             if(modulo == 1)/*+1*/ {
  18.                 res = -1;
  19.             }
  20.             else /*+2*/ res = +1;
  21.             }
  22.         else /*-*/ if(modulo == 1)/*-1*/ {
  23.                         res = +1;
  24.                         }
  25.                    else/*-2*/ res = -1;    
  26.     }
  27.     return res;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement