Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean hasPokerFlush(){
- int matches = 0;
- Card previousCard = new Card('x',-1);
- //go trough every card
- for(Card c:cards){
- //if card suits match
- if(c.getSuit()==previousCard.getSuit()){
- //increase matches variable by one
- matches++;
- }else{
- //else start again
- matches=0;
- }
- //if a deck has 5 suit matches it is a flush
- if(matches==5){
- return true;
- }
- previousCard = c;
- }
- //didn't find flush in deck, must be false
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement