title: Algorithm to avoid duplicate Cards in Card Game
body: <p>I made a rookie mistake, and am trying to figure out a fix without recoding the entire program.  Here's the scenario:</p>
  
  <p>I am creating 6 cards from a 52 card deck.  The cards have 2 fields: int rank and char suit.  I am pulling a random rank and suit and creating a new and unnamed instance of each card.  This is not accounting for duplicates.</p>
  
  <p>So I am creating the 6 cards successfully, but I do not want the duplicates.  This may be a newbish question, but we have all been there :)  Thanks for your help!</p>
  
  <hr>
  
  <pre><code>public void displayCards(List&lt;ImageView&gt; disp) {
          int cardNumber = 0;
          for (ImageView c : disp) {
  
              cardNumber++;
  
              rank = rand(13) + 2;
              int i = rand(4);
              if (i == 0) {
                  suit = 's';
              } else if (i == 1) {
                  suit = 'h';
              } else if (i == 2) {
                  suit = 'd';
              } else {
                  suit = 'c';
              }
  
              if (cardNumber == 1) {
                  dc1 = new Card(rank, suit);
              } else if (cardNumber == 2) {
                  dc2 = new Card(rank, suit);
              } else if (cardNumber == 3) {
                  dc3 = new Card(rank, suit);
              } else if (cardNumber == 4) {
                  pc1 = new Card(rank, suit);
              } else if (cardNumber == 5) {
                  pc2 = new Card(rank, suit);
              } else {
                  pc3 = new Card(rank, suit);
              }}
  </code></pre>