From 367c102bc5cd3d36a073db5bcebd27ea1c63f790 Mon Sep 17 00:00:00 2001 From: Giuli1297 Date: Sat, 23 Oct 2021 15:56:04 -0300 Subject: [PATCH] Poker --- src/roshka/bootcamp/poker/Carta.java | 42 ++++++++++++++++++++++++++++++++++++++++++ src/roshka/bootcamp/poker/PokerJuego.java | 261 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/roshka/bootcamp/poker/preguntas.md | 45 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 348 insertions(+) create mode 100644 src/roshka/bootcamp/poker/Carta.java create mode 100644 src/roshka/bootcamp/poker/PokerJuego.java create mode 100644 src/roshka/bootcamp/poker/preguntas.md diff --git a/src/roshka/bootcamp/poker/Carta.java b/src/roshka/bootcamp/poker/Carta.java new file mode 100644 index 0000000..fff1361 --- /dev/null +++ b/src/roshka/bootcamp/poker/Carta.java @@ -0,0 +1,42 @@ +package roshka.bootcamp.poker; + +import java.util.ArrayList; + +public class Carta { + private static final String[] palos = {"S", "C", "H", "D"}; + private static final String[] valores = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K", "A"}; + private String palo; + private String valor; + private String name; + private int numericValue; + + public Carta(String palo, String valor, int numericValue) { + this.palo = palo; + this.valor = valor; + this.numericValue = numericValue; + this.name = valor+palo; + } + + public String getPalo() { + return palo; + } + + + public String getValor() { + return valor; + } + + public static ArrayList crearMazo(){ + ArrayList mazo = new ArrayList(); + for(int i=0;i mazo = Carta.crearMazo(); + Carta[] mano = new Carta[5]; + int[] choices = new int[]{-1, -1, -1, -1, -1}; + boolean repeatedChoice = false; + Scanner in = new Scanner(System.in); + int i=0; + for(i=0;i<5;i++){ + repeatedChoice = false; + int choice = (int)(Math.random()*(52)); + for(int temp: choices){ + if(temp == choice){ + i--; + repeatedChoice = true; + } + } + if(repeatedChoice) continue; + choices[i] = choice; + mano[i] = mazo.get(choice); + } + Arrays.sort(mano, Comparator.comparing(Carta::getNumericValue).reversed()); + if(mano[1].getValor().equals("2") && mano[4].getValor().equals("A")){ + Carta temp = mano[0]; + mano[0] = mano[4]; + mano[4] = temp; + } + return mano; + } + + public void cartaAlta(){ + System.out.print("\nCarta Alta: *"); + for(Carta carta: mano){ + System.out.print("|"+carta.getValor()+""+carta.getPalo()+"|-"); + } + } + + public void doble(){ + String[] act = new String[5]; + boolean exist = false; + for(int i=0;i 1){ + exist = false; + break; + } + } + if(exist){ + System.out.print("\nEscalera: "); + for(int i=0;i 1 || + !(mano[0].getPalo().equals(mano[i + 1].getPalo()))){ + exist = false; + break; + } + } + if(exist){ + System.out.print("\nEscalera Color: "); + for(int i=0;i