/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package juegopoker; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; /** * * @author user */ public class JuegoPoker { private Cartas[] mano; /** * @param args the command line arguments */ public static void main(String[] args) { System.out.println("POKER PLAY\nSe genera la sogiente mano usuario" + "\n\tObtuviste las siguietnes combinaciones: "); JuegoPoker pokerJuego = new JuegoPoker(); pokerJuego.cartaAlta(); pokerJuego.doble(); pokerJuego.dobleDoble(); pokerJuego.trio(); pokerJuego.escalera(); pokerJuego.color(); pokerJuego.full(); pokerJuego.poker(); pokerJuego.escaleraColor(); } public JuegoPoker(){ this.mano = this.repartirCincoCartas(); this.mano = new Cartas[]{ new Cartas("H", "A", 14), new Cartas("H", "2", 2), new Cartas("H", "3", 3), new Cartas("H", "4", 4), new Cartas("H", "5", 5)}; Arrays.sort(mano, Comparator.comparing(Cartas::getNumericValue).reversed()); if(mano[1].getValor().equals("2") && mano[4].getValor().equals("A")){ Cartas temp = mano[0]; mano[0] = mano[4]; mano[4] = temp; } } public Cartas[] repartirCincoCartas(){ ArrayList mazo = Cartas.crearMazo(); Cartas[] mano = new Cartas[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(Cartas::getNumericValue).reversed()); if(mano[1].getValor().equals("2") && mano[4].getValor().equals("A")){ Cartas temp; temp = mano[0]; mano[0] = mano[4]; mano[4] = temp; } return mano; } public void cartaAlta(){ System.out.print("\nCarta Alta: *"); for(Cartas carta: mano){ System.out.print("|"+carta.getValor()+""+carta.getPalo()+"|-"); } } public void dobleDoble(){ String[] act = new String[5]; String firstDoble = null; boolean exist = false; int dobleCount = 0; 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