import java.util.Random;
import java.util.ArrayList;
public class Poker
{
private Random rnd;
private int cardA;
private int card2;
private int card3;
private int card4;
private int card5;
private int card6;
private int card7;
private int card8;
private int card9;
private int card10;
private int cardJ;
private int cardQ;
private int cardK;
private int[] hand;
private int isTwoOfAKind;
private int isTreeOfAKind;
private int isFull;
private int isPoker;
private int isStraight;
public Poker()
{
rnd = new Random();
hand = new int[5];
shoufleCards();
fillHand();
printHand();
isTwoOfAKind();
isTreeOfAKind();
isFull();
isStraight();
isPoker();
System.out.println("choose the cards u want to change");
}
public void shoufleCards()
{
cardA = rnd.nextInt(13)+1;
card2 = rnd.nextInt(13)+1;
card3 = rnd.nextInt(13)+1;
card4 = rnd.nextInt(13)+1;
card5 = rnd.nextInt(13)+1;
}
public void fillHand()
{
hand[0] = cardA;
hand[1] = card2;
hand[2] = card3;
hand[3] = card4;
hand[4] = card5;
}
public int[] getHand()
{
return hand;
}
public void printHand()
{
for(int index = 0; index < hand.length; index++)
{
if(hand[index]==1)
{
System.out.println("A");
}
else if(hand[index]==11)
{
System.out.println("j");
}
else if(hand[index]==12)
{
System.out.println("q");
}
else if(hand[index]==13)
{
System.out.println("k");
}
else
{
System.out.println(hand[index]);
}
}
}
public void chooseCards(int[] chooseCards)//inside the parameter u need to place the position of the card u want to change
{
for(int index = 0;index < chooseCards.length;index++)
{
int a = chooseCards[index];
hand[a] = rnd.nextInt(13)+1;
}
printHand();
isTwoOfAKind = 0;
isTreeOfAKind = 0;
isFull = 0;
isStraight = 0;
isPoker = 0;
isTwoOfAKind();
isTreeOfAKind();
isFull();
isStraight();
isPoker();
}
public void isTwoOfAKind()
{
int A = 0;
int two = 0;
int tree = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
int ten = 0;
int J = 0;
int Q = 0;
int K = 0;
for(int index = 0; index < hand.length;index++)
{
if(hand[index]==1) A++;
if(hand[index]==2) two++;
if(hand[index]==3) tree++;
if(hand[index]==4) four++;
if(hand[index]==5) five++;
if(hand[index]==6) six++;
if(hand[index]==7) seven++;
if(hand[index]==8) eight++;
if(hand[index]==9) nine++;
if(hand[index]==10) ten++;
if(hand[index]==11) J++;
if(hand[index]==12) Q++;
if(hand[index]==13) K++;
}
if(A == 2)
{
System.out.println("u got two of a kind with, aces");
isTwoOfAKind++;
}
if(two == 2)
{
System.out.println("u got two of a kind with, twos");
isTwoOfAKind++;
}
if(tree == 2)
{
System.out.println("u got two of a kind with, trees");
isTwoOfAKind++;
}
if(four == 2)
{
System.out.println("u got two of a kind with, fours");
isTwoOfAKind++;
}
if(five == 2)
{
System.out.println("u got two of a kind with, fives");
isTwoOfAKind++;
}
if(six == 2)
{
System.out.println("u got two of a kind with,");
isTwoOfAKind++;
}
if(seven == 2)
{
System.out.println("u got two of a kind with, sevens");
isTwoOfAKind++;
}
if(eight == 2)
{
System.out.println("u got two of a kind with, eights");
isTwoOfAKind++;
}
if(nine == 2)
{
System.out.println("u got two of a kind with, nines");
isTwoOfAKind++;
}
if(ten == 2)
{
System.out.println("u got two of a kind with, tens");
isTwoOfAKind++;
}
if(J == 2)
{
System.out.println("u got two of a kind with, Js");
isTwoOfAKind++;
}
if(Q == 2)
{
System.out.println("u got two of a kind with, Qs");
isTwoOfAKind++;
}
if(K == 2)
{
System.out.println("u got two of a kind with, Ks");
isTwoOfAKind++;
}
}
public void isTreeOfAKind()
{
int A = 0;
int two = 0;
int tree = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
int ten = 0;
int J = 0;
int Q = 0;
int K = 0;
for(int index = 0; index < hand.length;index++)
{
if(hand[index]==1) A++;
if(hand[index]==2) two++;
if(hand[index]==3) tree++;
if(hand[index]==4) four++;
if(hand[index]==5) five++;
if(hand[index]==6) six++;
if(hand[index]==7) seven++;
if(hand[index]==8) eight++;
if(hand[index]==9) nine++;
if(hand[index]==10) ten++;
if(hand[index]==11) J++;
if(hand[index]==12) Q++;
if(hand[index]==13) K++;
}
if(A == 3)
{
System.out.println("u got tree of a kind with, Aces");
isTreeOfAKind++;
}
if(two == 3)
{
System.out.println("u got tree of a kind with, twos");
isTreeOfAKind++;
}
if(tree == 3)
{
System.out.println("u got tree of a kind with, trees");
isTreeOfAKind++;
}
if(four == 3)
{
System.out.println("u got tree of a kind with, fours");
isTreeOfAKind++;
}
if(five == 3)
{
System.out.println("u got tree of a kind with, fives");
isTreeOfAKind++;
}
if(six == 3)
{
System.out.println("u got tree of a kind with, sixes");
isTreeOfAKind++;
}
if(seven == 3)
{
System.out.println("u got tree of a kind with, sevens");
isTreeOfAKind++;
}
if(eight == 3)
{
System.out.println("u got tree of a kind with, eights");
isTreeOfAKind++;
}
if(nine == 3)
{
System.out.println("u got tree of a kind with, nines");
isTreeOfAKind++;
}
if(ten == 3)
{
System.out.println("u got tree of a kind with,tens");
isTreeOfAKind++;
}
if(J == 3)
{
System.out.println("u got tree of a kind with, Js");
isTreeOfAKind++;
}
if(Q == 3)
{
System.out.println("u got tree of a kind with, Qs");
isTreeOfAKind++;
}
if(K == 3)
{
System.out.println("u got tree of a kind with, Ks");
isTreeOfAKind++;
}
}
public void isPoker()
{
int A = 0;
int two = 0;
int tree = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
int ten = 0;
int J = 0;
int Q = 0;
int K = 0;
for(int index = 0; index < hand.length;index++)
{
if(hand[index]==1) A++;
if(hand[index]==2) two++;
if(hand[index]==3) tree++;
if(hand[index]==4) four++;
if(hand[index]==5) five++;
if(hand[index]==6) six++;
if(hand[index]==7) seven++;
if(hand[index]==8) eight++;
if(hand[index]==9) nine++;
if(hand[index]==10) ten++;
if(hand[index]==11) J++;
if(hand[index]==12) Q++;
if(hand[index]==13) K++;
}
if(A == 4)
{
System.out.println("u got poker with, Aces");
isPoker++;
}
if(two == 4)
{
System.out.println("u got poker with, twos");
isPoker++;
}
if(tree == 4)
{
System.out.println("u got poker with, trees");
isPoker++;
}
if(four == 4)
{
System.out.println("u got poker with, fours");
isPoker++;
}
if(five == 4)
{
System.out.println("u got poker with, fives");
isPoker++;
}
if(six == 4)
{
System.out.println("u got poker with, sixes");
isPoker++;
}
if(seven == 4)
{
System.out.println("u got poker with, sevens");
isPoker++;
}
if(eight == 4)
{
System.out.println("u got poker with, eights");
isPoker++;
}
if(nine == 4)
{
System.out.println("u got poker with, nines");
isPoker++;
}
if(ten == 4)
{
System.out.println("u got poker with, tens");
isPoker++;
}
if(J == 4)
{
System.out.println("u got poker with, Js");
isPoker++;
}
if(Q == 4)
{
System.out.println("u got poker with, Qs");
isPoker++;
}
if(K == 4)
{
System.out.println("u got poker with, Ks");
isPoker++;
}
}
public void isFull()
{
if((isTwoOfAKind == 1) && (isTreeOfAKind == 1))
{
System.out.println("u got full");
isFull++;
}
}
public void isStraight()
{
int A = 0;
int two = 0;
int tree = 0;
int four = 0;
int five = 0;
int six = 0;
int seven = 0;
int eight = 0;
int nine = 0;
int ten = 0;
int J = 0;
int Q = 0;
int K = 0;
for(int index = 0; index < hand.length;index++)
{
if(hand[index]==1) A++;
if(hand[index]==2) two++;
if(hand[index]==3) tree++;
if(hand[index]==4) four++;
if(hand[index]==5) five++;
if(hand[index]==6) six++;
if(hand[index]==7) seven++;
if(hand[index]==8) eight++;
if(hand[index]==9) nine++;
if(hand[index]==10) ten++;
if(hand[index]==11) J++;
if(hand[index]==12) Q++;
if(hand[index]==13) K++;
}
if((A == 1)&&(two == 1)&&(tree == 1)&&(four == 1)&&(five == 1)&&(six == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((two == 1)&&(tree == 1)&&(four == 1)&&(five == 1)&&(six == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((tree == 1)&&(four == 1)&&(five == 1)&&(six == 1)&&(seven == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((four == 1)&&(five == 1)&&(six == 1)&&(seven == 1)&&(eight == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((five == 1)&&(six == 1)&&(seven == 1)&&(eight == 1)&&(nine == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((six == 1)&&(seven == 1)&&(eight == 1)&&(nine == 1)&&(ten == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((seven == 1)&&(eight == 1)&&(nine == 1)&&(ten == 1)&&(J == 1))
{
System.out.println("tenes escalera");
isStraight++;
}
if((eight == 1)&&(nine == 1)&&(ten == 1)&&(J == 1)&&(Q == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((nine == 1)&&(ten == 1)&&(J == 1)&&(Q == 1)&&(K == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
if((ten == 1)&&(J == 1)&&(K == 1)&&(Q == 1)&&(A == 1))
{
System.out.println("u got Straight!");
isStraight++;
}
}
}