Combinations of integers
Hello is there anyone there who can help me? I am writing a program that evaluates poker hands. I need a way of creating all 2 card combinations from the list of all cards not yet dealt.
I have 4 arrays that store the undealt cards off each suit. I now need to search one of the arrays and find the first instance of an undealt card and fix this card as card 1. I then want to recursively search the rest of this array and the 3 other arrays each time returning the values of the cards not yet dealt. I have tried a few methods but either can only print out different pairs and not different combinations or i get a StackOverFlowError.
below is the code I have currently.
publicvoid selectCards(){
//p = new PokerHand();
added = 0;
//fix first card
while(added == 0){
for(int i=0;i<tothearts.length;i++){//tothearts is the array containin the hearts
if(tothearts[i] == 1){
PokerCard c1 =new PokerCard(i,PokerCard.HEARTS);//create an instance of a card with rank i & suit
p.addCard(c1);
tothearts[i] = 0;//remove this card so that duplicate cards arent included
added++;
break;
}
}
}
while(added >= 1 && added <=2){
for(int i=0;i<tothearts.length;i++){//tothearts is the array containin the hearts
if(tothearts[i] == 1){
PokerCard c1 =new PokerCard(i,PokerCard.HEARTS);//create an instance of a card with rank i & suit
p.addCard(c1);
tothearts[i] = 0;//remove this card so that duplicate cards arent included
added++;
System.out.println("Hand = "+p);
p.removeCard(p.getHand().size()-1);
break;
}
}
}
selectCards();
}
The above code is only for one suit eventually i want to be able to do it for all four suits
here is my output:
My hand = 7c qd ah 5h jc 8c 9c
Opponents hand = ? ? ah 5h jc 8c 9c
Hand = 2h 3h
Hand = 2h 4h
Hand = 2h 6h 7h
Hand = 2h 6h 8h
Hand = 2h 6h 9h 10h
Hand = 2h 6h 9h jh
Hand = 2h 6h 9h qh kh
If anyone could point out to me where i am going wrong that would be helpful.">

