title: Texas Hold'em poker recognizing full house
body: <p>I'm creating a console texas hold'em poker. I'm already done making this game, everything works as supposed, expect for a full house for which I became undecided for a best way to write a code.</p>
  
  <p>This is how I present cards: "D5", "S2", "SA"... I know it is a bad idea of representing cards, but I'm currently not thinking in OOP way, I'm actually playing around with indexes, which is a good code practice.</p>
  
  <p>So, the problem isn't how to write a pair or three of a kind, I actually had a great idea to do something like this...</p>
  
  <pre><code>if (isPair() &amp;&amp; isThreeOfKind()) {
     //
  }
  </code></pre>
  
  <p>But it is impossible, because I'm dealing with a problem (for which I'm here),
  <code>isPair()</code> and <code>isThreeOfAKind()</code> will find a same card, let's say <code>"DA", "CA", "SA"</code>, so we have a pair of <code>"DA"</code> and <code>"CA"</code>, but also <code>"DA", "CA", "SA"</code> which stays for a three of a kind.</p>
  
  <p>code update:</p>
  
  <pre><code>public boolean isPair(int playerIndex) {
          boolean isPair = false;
  
          if (hasSameRank(playerAndHand[playerIndex])) {
              isPair = true;
          } else {
              for (int i = 0; i &lt; TABLE_CARDS_LENGTH; i++) {
                  for (int j = 0; j &lt; HAND_CARDS_LENGTH; j++) {
                      if (playerAndHand[playerIndex][j].charAt(1) == tableCards[i].charAt(1)) {
                          isPair = true;
                          break;
                      }
                  }
                  if (isPair) break; 
              }
          }
          return isPair;
      }
  
  public boolean isThreeOfKind(int playerIndex) {
          boolean isThreeOfKind = false;
  
          // 2 from player hand 1 from table
          if (hasSameRank(playerAndHand[playerIndex])) {
              for (int i = 0; i &lt; TABLE_CARDS_LENGTH; i++) {
                  if (playerAndHand[playerIndex][0].charAt(1) == tableCards[i].charAt(1)) {
                      isThreeOfKind = true;
                      break;
                  }
              }
          } else {
              for (int i = 0; i &lt; TABLE_CARDS_LENGTH; i++) {
                  // first card in player hand and 2 more on table
                  if (playerAndHand[playerIndex][0].charAt(1) == tableCards[i].charAt(1)) {
                      for (int j = 0; j &lt; TABLE_CARDS_LENGTH; j++) {
                          if (j != i) {
                              if (playerAndHand[playerIndex][0].charAt(1) == tableCards[j].charAt(1)) {
                                  isThreeOfKind = true;
                                  break;
                              }
                          } else {
                              continue;
                          }
                      }
                      if (isThreeOfKind) break;
                      // second card in player hand and 2 more on table   
                  } else if (playerAndHand[playerIndex][1].charAt(1) == tableCards[i].charAt(1)) {
                      for (int j = 0; j &lt; TABLE_CARDS_LENGTH; j++) {
                          if (j != i) {
                              if (playerAndHand[playerIndex][1].charAt(1) == tableCards[j].charAt(1)) {
                                  isThreeOfKind = true;
                                  break;
                              }
                          } else {
                              continue;
                          }
                      }
                      if (isThreeOfKind) break;
                  }                   
              }
          }
          return isThreeOfKind;
      }
  </code></pre>