Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. boolean hasPokerFlush(){
  2.  
  3. int matches = 0;
  4. Card previousCard = new Card('x',-1);
  5.  
  6. //go trough every card
  7. for(Card c:cards){
  8.  
  9. //if card suits match
  10. if(c.getSuit()==previousCard.getSuit()){
  11.  
  12. //increase matches variable by one
  13. matches++;
  14. }else{
  15.  
  16. //else start again
  17. matches=0;
  18. }
  19.  
  20. //if a deck has 5 suit matches it is a flush
  21. if(matches==5){
  22. return true;
  23. }
  24.  
  25. previousCard = c;
  26. }
  27.  
  28. //didn't find flush in deck, must be false
  29. return false;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement