I'm pretty new to java and I'm working on an assignment. I need to go through a number of cards, determine if all of them are facing up and if they ALL are, then return a congratulatory message.
I'm working on the code for looping through the cards to determine if they are all facing up or not. Right now, the code doesn't seem to be checking all the cards before returning a "true".
Is it possible to use an if statement within a for loop or am I doing it all wrong?
public boolean checkAllMatchesFound() {
for (int i=0; i<MatchingGame.NUMBER_OF_CARDS; i++) {
if ((cards[i].isFacingUp()) == true);
return true;
}
return false;
}
Aucun commentaire:
Enregistrer un commentaire