Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Compara si una jugada (this) gana a otra jugada.
- * En concreto, devuelve:
- * 0 si una (this) y otra empatan;
- * -1 si una (this) gana a la otra;
- * +1 si una (this) pierde con la otra.
- * @param otra Jugada
- * @return int
- */
- public int ganaA(Jugada otro) {
- int res = 0;
- int operacion = this.getEleccion() - otro.getEleccion();
- int modulo = (int) Math.abs(operacion);
- int signo = (int) Math.signum(operacion);
- if(operacion != 0) {
- if(signo == 1)/*+*/ {
- if(modulo == 1)/*+1*/ {
- res = -1;
- }
- else /*+2*/ res = +1;
- }
- else /*-*/ if(modulo == 1)/*-1*/ {
- res = +1;
- }
- else/*-2*/ res = -1;
- }
- return res;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement