Commit 3944d7cf by Jose Baez

Se crea metodo full

parent cb4a47c9
......@@ -19,6 +19,10 @@ public class Juego {
siguiente = false;
System.out.println("POKER");
}
if (siguiente && full(cartas)) {
siguiente = false;
System.out.println("FULL");
}
if (siguiente && escalera(cartas)) {
siguiente = false;
System.out.println("ESCALERA");
......@@ -31,6 +35,41 @@ public class Juego {
System.out.println("NADA");
}
}
//Dos cartas iguales (mismo valor) junto con tres cartas iguales (mismo valor).
public boolean full(List<Carta> cartas) {
List<Integer> valores = new ArrayList<>();
for (Carta c : cartas) {
valores.add(extraer(c.valor));
}
Collections.sort(valores);
int counter=0;
int numero=0;
int cantidadNumero=0;
int cantidadNumero2=0;
for(int i=1; i<14; i++){
for (int j=0; j<valores.size(); j++) {
int s= valores.get(j);
if(s == i){
counter++;
}
}
if(counter > cantidadNumero){
numero=i;
cantidadNumero=counter;
cantidadNumero2=counter;
}
if((counter-1) > cantidadNumero){
cantidadNumero2=counter;
}
counter=0;
}
if (cantidadNumero==3 && (cantidadNumero2-1)==2){
return true;
}else {
return false;
}
}
//Cuatro cartas iguales (mismo valor).
public boolean poker(List<Carta> cartas) {
......
......@@ -10,10 +10,10 @@ public class Main {
List<Carta> cartas = new ArrayList<>();
cartas = Arrays.asList(
new Carta("2H"),
new Carta("6H"),
new Carta("6H"),
new Carta("6S"),
new Carta("6H")
new Carta("2H"),
new Carta("7H"),
new Carta("7S"),
new Carta("7H")
);
cartas.forEach(System.out::print);
......
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