title: Java Poker Game Program
body: <p>I'm working on this poker game project and I'm stuck on how to print out the card types and the default "sorry, you lost" at the end of the function. I'm not sure if my code is correct, I would appreciate any type of help. </p>
  
  <p>Basically, my program needs to print out:</p>
  
  <pre><code>       [A Spades, 10 Spades, Q Spades, J Spades, K Spades] 
         Royal Flush!
           --------------------------------------------------
  
          [9 Spades, 10 Spades, Q Spades, J Spades, K Spades]
           Straight Flush!
           --------------------------------------------------
  </code></pre>
  
  <p>etc... </p>
  
  <p>but my program only prints out:</p>
  
  <pre><code>          [A Spades, 10 Spades, Q Spades, J Spades, K Spades]
  </code></pre>
  
  <p>I'm having trouble printing the type (Royal Flush part). </p>
  
  <pre><code>/**
   * Check current currentHand using multipliers and goodHandTypes arrays Must
   * print yourHandType (default is "Sorry, you lost") at the end of function.
   * This can be checked by testCheckHands() and main() method.
   */
  private void checkHands() {
      // implement this method!
    List&lt;Card&gt; sortedHand = new ArrayList&lt;Card&gt;(currentHand);
    Collections.sort(sortedHand, new Comparator&lt;Card&gt;() {
  
  @Override
  
  public int compare(Card card1, Card card2) {
      int rank1 = card1.getRank();
      int rank2 = card2.getRank();
  
      if (rank1 &gt; rank2) {
          return 1;
      }
  
      if (rank1 &lt; rank2){
          return -1;
      }
  
  
  
      return 0;
  }
  
    }
  
  
      int rank = 0;
      String ranks;
  
      if (isRoyalPair() == true) {
          rank = 1;
       if (isTwoPair() == true) {
          rank = 2;
      }
      if (isThreeOfAKind() == true) {
          rank = 3;
      }
  
      if (isStraight() == true) {
          rank = 4;
      }
      if (isFlush() == true) {
          rank = 5;
      }
      if (isFullHouse() == true) {
          rank = 6;
      }
      if (isFourOfAKind() == true) {
          rank = 7;
      }
      if (isStraightFlush() == true) {
          rank = 8;
      }
      if (isRoyalFlush() == true) {
          rank = 9;
      }
      }
  
      rank -= 1;
      if (rank &lt; 0) {
          ranks = "Sorry, you lost!";
  
      } else {
          ranks = goodHandTypes[rank];
      }
  
      System.out.println("" + ranks);
  
  
  
      switch (ranks) {
         case "1":
              this.balance += (this.bet * multipliers[0]);
              break;
          case "2":
             this.balance += (this.bet * multipliers[1]);
              break;
          case "3":
             this.balance += (this.bet * multipliers[2]);
              break;
         case "4":
             this.balance += (this.bet * multipliers[3]);
              break;
          case "5":
             this.balance += (this.bet * multipliers[4]);
              break;
          case "6":
              this.balance += (this.bet * multipliers[5]);
             break;
          case "7":
              this.balance += (this.bet * multipliers[6]);
             break;
          case "8":
              this.balance += (this.bet * multipliers[7]);
              break;
          case "9":
              this.balance += (this.bet * multipliers[8]);
              break;
          default:
              break;
  
  
              }
            }
  </code></pre>
  
  <p>and I already have all my methods for them, I just need help in finding a way to print them: </p>
  
  <pre><code>    private boolean isStraight() {
  
      for (int i = 0; i &lt; numberOfCards; i++) {
  
          if (currentHand.get(i).getRank() != currentHand.get(i + 1).getRank()) {
  
              return false;
  
          }
  
      }
  
      return true;
  
  }
  
  private boolean isFlush() {
      for (int i = 0; i &lt; numberOfCards; i++) {
          if (currentHand.get(i).getSuit() != currentHand.get(i + 1).getSuit()) {
              return false;
          }
  
      }
  
      return true;
  }
  
  private boolean isStraightFlush() {
      if (isStraight() == true &amp;&amp; isFlush() == true) {
          return true;
      }
      return false;
  }
  
  private boolean isRoyalFlush() {
      if (isFlush() == false || isStraight() == false) {
          return false;
      } else {
          if (currentHand.get(0).getRank() == 10) {
              return true;
          }
          return false;
      }
  
  }
  
  private boolean isFourOfAKind() {
  
      //runs thru the hand for exactly 4 matches
  
      for (int i = 0; i &lt; numberOfCards - 1; i++) {
  
          int counter = 0;
  
          for (int y = i + 1; y &lt; numberOfCards; y++) {
  
              if (currentHand.get(i).getRank() == currentHand.get(0).getRank()) {
  
                  counter++;
              }
  
          }
  
          if (counter == 4) {
  
              return true;
  
          } else {
              return false;
          }
  
      }
      return false;
  }
  
  private boolean isFullHouse() {
      if (isThreeOfAKind() == true &amp;&amp; isOnePair() == true) {
          return true;
      } else {
          return false;
      }
  }
  
  private boolean isThreeOfAKind() {
  
  
      //matches three
  
      for (int i = 0; i &lt; numberOfCards; i++) {
  
          int counter = 0;
  
          for (int y = 0; y &lt; numberOfCards; y++) {
  
              if (currentHand.get(i).getRank() == currentHand.get(y).getRank()) {
  
                  counter++;
  
                  for (int x = 0; x &lt; numberOfCards; x++) {
  
                      if (currentHand.get(i).getRank() == currentHand.get(x).getRank()) {
  
                          counter++;
                      }
                  }
  
  
                  if (counter == 3) {
                      return true;
  
  
                  } else {
  
  
                      return false;
  
  
  
  
  
                  }
              }
  
  
  
  private boolean isTwoPair() {
      //check if it is four of a kind or two pair))
      if (isFourOfAKind() == true) {
          return false;
      }
      int numberOfPair = 0;
      int counter = 1;
  
      return false;
  }
  
  private boolean isOnePair() {
      return false;
  }
  
  public boolean isRoyalPair() {
  
      if (isOnePair() == false &amp;&amp; isTwoPair() == false &amp;&amp; isThreeOfAKind() == false &amp;&amp; isFourOfAKind() == false
              &amp;&amp; isFullHouse() == false &amp;&amp; isRoyalFlush() == false &amp;&amp; isFlush() == false &amp;&amp; isStraight() == false &amp;&amp; isStraightFlush() == false) {
  
          return true;
      }
  
  
  
      return false;
  }
  </code></pre>