java testing a boolean method
Ok, I'm still a ways from done on CrazyEights, and I got sidetracked wondering how the if statement works on a Boolean. So I made up this little test to check if a Boolean is false or true.
Not sure what purpose it will serve yet, but I wanted it.
private int testing(boolean method) {
int test = 1;
if(method) {
test = 0;
}
System.out.println("testing method: " + test);
return test;
}
I have encountered yet another gameplay issue. If an invalid card is entered, but it is a card in your hand, It is removing it..... I only have one method that removes my cards, and it is not executing, so I need to find out why it is removing the cards from my hand.
I'm pretty sure the card is being removed in this function.... But HOW!!!
Update:
The problem was in my Hands class. For some crazy reason I had this function removing the card if it was found. When the isValidPlay(); was running, it was checking if the card was in my hand, and this function was removing it.
public boolean contains(Card card) {
int index = 0;
boolean contains = false;
System.out.println(" Hands.contains is executing");
while(!contains && index < cards.size()) {
Card compareCard = cards.get(index);
if(compareCard.equals(card)) {
cards.remove(index);
contains = true;
}
else {
index++;
}
}
return contains;
}
Not sure what purpose it will serve yet, but I wanted it.
private int testing(boolean method) {
int test = 1;
if(method) {
test = 0;
}
System.out.println("testing method: " + test);
return test;
}
I have encountered yet another gameplay issue. If an invalid card is entered, but it is a card in your hand, It is removing it..... I only have one method that removes my cards, and it is not executing, so I need to find out why it is removing the cards from my hand.
I'm pretty sure the card is being removed in this function.... But HOW!!!
Update:
The problem was in my Hands class. For some crazy reason I had this function removing the card if it was found. When the isValidPlay(); was running, it was checking if the card was in my hand, and this function was removing it.
public boolean contains(Card card) {
int index = 0;
boolean contains = false;
System.out.println(" Hands.contains is executing");
while(!contains && index < cards.size()) {
Card compareCard = cards.get(index);
if(compareCard.equals(card)) {
cards.remove(index);
contains = true;
}
else {
index++;
}
}
return contains;
}
Comments
Post a Comment