Can someone see what is wrong with this? Im stumped
publicclass Card{
int suit;
int value;
staticint isStraight = 0;
staticint isFlush = 0;
staticint handCounter = 0;
staticint cardCounter = 0;
boolean inUse =false;
publicint getSuit(){
return suit;
}
publicvoid setSuit(int suit){
this.suit = suit;
}
publicint getValue(){
return value;
}
publicvoid setValue(int value){
this.value = value;
}
publicboolean isInUse(){
return inUse;
}
publicvoid setInUse(boolean inUse){
this.inUse = inUse;
}
publicstaticint checkPairs(int[] handValues){
for (int x = 0; x<5; x++ ){
for (int y = 0; y<5; y++ ){
if(handValues[x]==handValues[y]){
cardCounter ++;
}
}
handCounter = handCounter + (cardCounter - 1);
cardCounter = 0;
}
System.out.println(handCounter);
return handCounter;
}
publicstaticint checkStraight(int[] handValues){
if(handValues[0] == (handValues[1]-1)){
if (handValues[1] == (handValues[2]-1)){
if (handValues[2] == (handValues[3]-1)){
if (handValues[3] == (handValues[4]-1)){
///System.out.println("straight");
isStraight = 1;
if (handValues[4] == 12){
isStraight = 2;
}
}
}
}
}
return isStraight;
}
publicstaticint checkFlush(Card[]inputHand){
if (inputHand[0].suit == inputHand[1].suit){
if (inputHand[1].suit == inputHand[2].suit){
if (inputHand[2].suit == inputHand[3].suit){
if (inputHand[3].suit == inputHand[4].suit){
isFlush = 1;
}
}
}
}
return isFlush;
}
}
//handCheckerApp ,
import tcdIO.*;
publicclass handCheckerApp{
///these string arrays just hold the names of the values
static String[] suitsArray ={"hearts" ,"spades" ,"diamonds" ,"clubs"};
static String[] valuesArray ={"two" ,"three" ,"four" ,"five" ,"six" ,"seven" ,"eight" ,"nine" ,"ten" ,"jack" ,"queen" ,"king" ,"ace"};
publicstaticvoid main (String arguments []){
Terminal terminal =new Terminal();
Card[] inputHand =new Card[5];
Card[] deck =new Card[52];
Card currentCard =new Card();
for(int number = 0 ; number <= 12 ; number++){
deck[number]=new Card();
deck[number].suit = 0;
deck[number].value = number;
}
for(int number = 13 ; number <= 25 ; number++){
deck[number]=new Card();
deck[number].suit = 1;
deck[number].value = (number - 13);
}
for(int number = 26 ; number <= 38 ; number++){
deck[number]=new Card();
deck[number].suit = 2;
deck[number].value = (number - 26);
}
for(int number = 39 ; number <= 51 ; number++){
deck[number]=new Card();
deck[number].suit = 3;
deck[number].value = (number - 39);
}
terminal.println("Poker Hand Checker");
terminal.println("~~~~~~~~~~~~~~~~~~");
terminal.println("Suits key:..Hearts = 1");
terminal.println("...................Spades = 2");
terminal.println("...................Diamonds = 3");
terminal.println("...................Clubs = 4");
terminal.println(".............................");
terminal.println("Values key:.Twos = 2");
terminal.println("......................Threes = 3");
terminal.println("......................Fours = 4");
terminal.println("......................Fives = 5");
terminal.println("......................Sixes = 6");
terminal.println("......................Sevens = 7");
terminal.println("......................Eights = 8");
terminal.println("......................Nines = 9");
terminal.println("......................Tens = 10");
terminal.println("......................Jacks = 11");
terminal.println("......................Queens = 12");
terminal.println("......................Kings = 13");
terminal.println("......................Aces = 14");
///this block of code marks cards in the deck as in use and adds them to the hand
for(int i = 0; i < 5; i++){///for1
currentCard.value = (terminal.readInt("please enter card " + (i+1) +" value: " )-2);
currentCard.suit = (terminal.readInt("please enter card " + (i+1) +" suit: " )-1);
for (int x = 0; x< 52; x++){///for2
if (deck[x].value == currentCard.value){///if1
if (deck[x].suit == currentCard.suit){///if2
if (deck[x].inUse ==true){///elseif1
terminal.println("you chose that card already");
i--;
}///if3
elseif(deck[x].inUse ==false){///if3
deck[x].inUse =true;
inputHand[i] = deck[x];
terminal.println("this card is the " + valuesArray[(inputHand[i].value)] +" of " + suitsArray[(inputHand[i].suit )]);
}///elseif1
}///if2
}///if1
}///for2
}///for1
int handValues[] ={inputHand[0].value, inputHand[1].value, inputHand[2].value, inputHand[3].value, inputHand[4].value};
java.util.Arrays.sort(handValues);
///this method checks for pairs, two pairs, three of a kind, full house & four of a kind
Card.checkPairs(handValues);
if (Card.handCounter == 2){
terminal.println("You have a pair");
}
if (Card.handCounter == 4){
terminal.println("You have two pair");
}
if (Card.handCounter == 6){
terminal.println("You three of a kind");
}
if (Card.handCounter == 8){
terminal.println("You have a full house");
}
if (Card.handCounter == 12){
terminal.println("You have four of a kind");
}else{
terminal.println("");
}
Card.checkStraight(handValues);
Card.checkFlush(inputHand);
if (Card.isStraight == 1 && Card.isFlush == 0){
terminal.println("You have a straight");
}
if (Card.isStraight == 1 && Card.isFlush == 1){
terminal.println("You have a straight flush");
}
if (Card.isStraight == 2 && Card.isFlush == 0){
terminal.println("You have a royal straight");
}
if (Card.isStraight == 2 && Card.isFlush == 1){
terminal.println("You have a royal straight flush");
}
if (Card.isStraight == 0 && Card.isFlush == 1){
terminal.println("You have a flush");
}
if (Card.isStraight == 0 && Card.isFlush == 0){
terminal.println("");
}
}
}
Okay it's not recognising deck.inUse....i can't see why.
Can someone possibly point out some suggestions. Thanks, much appreciated.

