Commit 2307da70 by Emanuel Lugo

pokerGame2 terminado

parent 63e14615
{
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=4 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx2G -Xms100m"
}
\ No newline at end of file
package poker;
import java.util.Objects;
public class Carta {
public String valor;
......@@ -40,10 +41,39 @@ public class Carta {
return this.valor + this.palo;
}
//VER OPCINES DE SOLUCIONAR LETRAS
public int getValorInt() {
int aux = Integer.parseInt(this.valor);
int result = 0;
try {int aux = Integer.parseInt(this.valor);
return aux;
}
catch (Exception e) {
switch (this.valor) {
case "T":
result = 10;
break;
case "J":
result = 11;
break;
case "Q":
result = 12;
break;
case "K":
result = 13;
break;
case "A":
result = 14;
break;
}
return result;
}
}
......@@ -52,4 +82,23 @@ public class Carta {
}
public void setValor(String nuevoValor){
this.valor = String.valueOf(nuevoValor.charAt(0));
this.palo = String.valueOf(nuevoValor.charAt(1));
}
@Override
public boolean equals(Object b) {
Carta cartab = (Carta) b ;
if (this.valor.equals(cartab.valor) && (this.palo.equals(cartab.palo))) {
return true;
}else
return false;
}
@Override
public int hashCode() {
return Objects.hash(this.valor, this.palo);
}
}
......@@ -19,6 +19,18 @@ public class pokerGame {
// COMPROBACIÓN DE CASOS DE CARTAS EN SECUENCIA - ESCALERA COLOR - ESCALERA -
// COLOR
for (int i = 0; i < 4; i++) {
}
for (int i = 0; i < 4; i++) {
// System.out.println(mano.get(i).getValorInt() + ": valor carta1");
// System.out.println(mano.get(i+1).getValorInt() + ": valor carta2");
......@@ -36,7 +48,7 @@ public class pokerGame {
}
if (contadorValor == 3 && mano.get(0).getValorInt() == 1 && mano.get(4).getValorInt() == 13) {
return resultado = "ESCALERA COLOR";
return resultado = "ESCALERA";
}
if (contadorValor == 4 && contadorPalo == 4) {
return resultado = "ESCALERA COLOR";
......@@ -106,28 +118,4 @@ public class pokerGame {
}
}
/*
* PARA TESTEAR
* Collections.sort(mano, new SortbyPalo());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*
* Collections.sort(mano, new SortbyValor());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*
* Collections.sort(mano, new SortbyValor());
*
* System.out.println("");
*
* for (i = 0; i < mano.size(); i++)
* System.out.println(mano.get(i).valorPalo());
*/
\ No newline at end of file
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment