From c4afadba52d82357ef78a10c48aeb918d0fdc326 Mon Sep 17 00:00:00 2001 From: JoseBaezx Date: Wed, 27 Apr 2022 11:08:59 -0400 Subject: [PATCH] Se crea metodo par doble --- Juego.java | 25 +++++++++++++++++++++++++ Main.java | 6 +++--- out/production/poker/Juego.class | Bin 6475 -> 0 bytes out/production/poker/Main.class | Bin 2127 -> 0 bytes 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Juego.java b/Juego.java index b69ba4e..bb7fa31 100644 --- a/Juego.java +++ b/Juego.java @@ -34,10 +34,35 @@ public class Juego { siguiente = false; System.out.println("TRIO"); } + if (siguiente && parDoble(cartas)) { + siguiente = false; + System.out.println("PAR DOBLE"); + } if (siguiente) { System.out.println("NADA"); } } + + public boolean parDoble(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 == 2) { + return true; + } + } + } + } + return false; + } public boolean trio(List cartas) { List valores = new ArrayList<>(); for (Carta c : cartas) { diff --git a/Main.java b/Main.java index 46929ab..81715a8 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("QH"), - new Carta("QH"), + new Carta("TC"), new Carta("TS"), - new Carta("9C") + new Carta("AC") ); cartas.forEach(System.out::print); diff --git a/out/production/poker/Juego.class b/out/production/poker/Juego.class index 3fd6127..b5ebb3c 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 8496137..d227a20 100644 Binary files a/out/production/poker/Main.class and b/out/production/poker/Main.class differ -- libgit2 0.26.0