Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. private static boolean isStraight(String[] _cards)
  2. {
  3. FastList<String> tempCards = new FastList<String>();
  4. FastList<String> temp = new FastList<String>();
  5.  
  6. //remove duplicates
  7. for (int i = 0; i < _cards.length; i++)
  8. {
  9. if (temp.contains(_cards[i].substring(1)))
  10. continue;
  11. temp.add(_cards[i].substring(1));
  12. tempCards.add(_cards[i]);
  13. }
  14.  
  15. //check if without duplicate the list size at least is 5 or else it cant be flush
  16. if (tempCards.size() < 5)
  17. return false;
  18.  
  19. for (int i = 0 ; i < tempCards.size(); i++)
  20. System.out.println(tempCards.get(i));
  21. //arrange cards from big to small
  22. System.out.println("organized to");
  23. Object[] tryer = tempCards.toArray();
  24.  
  25. for ( int i = 0 ; i < tryer.length; i++ )
  26. {
  27. for (int x = i +1 ; x < tryer.length ; x++)
  28. {
  29. if (Integer.parseInt(String.valueOf(tryer[i]).substring(1)) < Integer.parseInt(String.valueOf(tryer[x]).substring(1)))
  30. {
  31. String temp2 = String.valueOf(tryer[i]);
  32. tryer[i] = tryer[x];
  33. tryer[x] = temp2;
  34.  
  35. }
  36. }
  37. }
  38.  
  39. for (int i = 0 ; i < tryer.length; i++)
  40. System.out.println(tryer[i]);
  41.  
  42. //check if straight then return true and send the heights card rank of the straight(not yet)
  43.  
  44. return false;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement