From 53958d7cad4938062858867dd1f2458643516147 Mon Sep 17 00:00:00 2001 From: JoseBaezx Date: Wed, 27 Apr 2022 11:30:38 -0400 Subject: [PATCH] Poker app final 1.0 --- Juego.java | 40 +++++++++++++++++++++++++++++++++------- Main.java | 8 ++++---- out/production/poker/Juego.class | Bin 6916 -> 0 bytes out/production/poker/Main.class | Bin 2143 -> 0 bytes 4 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Juego.java b/Juego.java index bb7fa31..f0c49ac 100644 --- a/Juego.java +++ b/Juego.java @@ -38,11 +38,35 @@ public class Juego { siguiente = false; System.out.println("PAR DOBLE"); } + if (siguiente && par(cartas)) { + siguiente = false; + System.out.println("PAR"); + } if (siguiente) { - System.out.println("NADA"); + System.out.println("CARTA ALTA"); } } + public boolean par(List cartas) { + if(comprobarPalo(cartas)<3) { + List valores = new ArrayList<>(); + for (Carta c : cartas) { + valores.add(extraer(c.valor)); + } + Collections.sort(valores); + int[] numerosArray = pasarAArray(valores); + int con = 0; + for (int i = 0; i < numerosArray.length - 1; i++) { + if (numerosArray[i] == numerosArray[i + 1]) { + con++; + if (con == 1) { + return true; + } + } + } + } + return false; + } public boolean parDoble(List cartas) { if(comprobarPalo(cartas)<3) { List valores = new ArrayList<>(); @@ -69,18 +93,20 @@ public class Juego { valores.add(extraer(c.valor)); } //Collections.sort(valores); + int[] numerosArray = pasarAArray(valores); int counter=0; - int numero=0; int cantidadNumero=0; for(int i=11; i<14; i++){ - for (int j=0; j cantidadNumero){ - numero=i; + cantidadNumero=counter; } counter=0; @@ -229,7 +255,7 @@ public class Juego { valores.add(extraer(c.valor)); } Collections.sort(valores); - valores.forEach(System.out::println); + //valores.forEach(System.out::println); int[] valoresArry = pasarAArray(valores); for (int i = 0; i < valoresArry.length - 1; i++) { diff --git a/Main.java b/Main.java index 81715a8..b4a2e2f 100644 --- a/Main.java +++ b/Main.java @@ -9,11 +9,11 @@ public class Main { List cartas = new ArrayList<>(); cartas = Arrays.asList( - new Carta("AH"), - new Carta("QH"), + new Carta("TH"), + new Carta("TD"), new Carta("TC"), - new Carta("TS"), - new Carta("AC") + new Carta("4D"), + new Carta("AD") ); cartas.forEach(System.out::print); diff --git a/out/production/poker/Juego.class b/out/production/poker/Juego.class index b5ebb3c..4328030 100644 Binary files a/out/production/poker/Juego.class and b/out/production/poker/Juego.class differ diff --git a/out/production/poker/Main.class b/out/production/poker/Main.class index d227a20..eea2f97 100644 Binary files a/out/production/poker/Main.class and b/out/production/poker/Main.class differ -- libgit2 0.26.0