i have this script, and it is suppose identifier if a player can assist to the suit of a specific card. So, if he assist, show the message, you assist, no problem, but if he does bluff the verification never is done and show the else System.out.println(hand);
the result of this else is [SEVEN of DIAMONDS, FOUR of SPADES, SEVEN of SPADES, KING of DIAMONDS, more cards]
pn50.getText() (the result of this is CLUBS for example)
my doubt is, what reason the line hand.subList(0, 10).contains(pn50.getText()) never finds nothing in the list (that is the hand of the player)
for example, if the player one plays the king of hearts, and the player two plays the seven of clubs and have the three of hearts in the hand, it is suppose show the message “play another”
@Override
public boolean validCard(List<Card> hand, JTextField pn70, JTextField pn50, int i) {
if(pn70.getText().equals (pn50.getText())) {
System.out.println("you assist");
return true;
} else {
if (hand.subList(0, 10).contains(pn50.getText())) {
System.out.println("play another");
}
else
System.out.println(hand);
}
return false;
}
any help?
thanks
The easiest solution here is to just replace the call to
containswith a loop: