title: How to deal deck of Cards to players?
body: <p>I have been trying to create a basic card game(experiment) using java. After shuffling the deck of cards, I need to pass 6 shuffled cards to each player based on number of players which took participated in the game. (Max 6 players)</p>
  
  <p>By using setHand() method in "Player" class, I was able to dislay 6 cards but after starting the game, in main method by looping through the players, I was shown only 2 cards if there is ever 2 players.</p>
  
  <pre><code>    public static void main (String[] args) {
          //Create players between 2-6
          Game newGame = new Game();
          List&lt;Player&gt; players = newGame.createPlayers();
  
          //Let user decide the number of cards set either 24 or 36 or 52 and create deck
          if(players != null){
              newGame.createDeck(players);
  
              for (Player player: players){
                      player.showHand();
              }
          }
  
      }
  </code></pre>
  
  <pre><code>public class Game {
      private Dealer dealer;
      private List&lt;Player&gt; players = new ArrayList&lt;&gt;();
      private int numberOfPlayers;
  
      public List&lt;Player&gt; createPlayers(){
          Scanner scanner = new Scanner(System.in);
          System.out.println("Number of players(up to 6)");
          numberOfPlayers = scanner.nextInt();
          if(numberOfPlayers &lt;= 6) {
              int count = 0;
              while (count &lt; numberOfPlayers) {
                  System.out.println("Please enter the names");
                  String playerName = scanner.next();
                  players.add(new Player(playerName));
                  count++;
              }
              return players;
          }else{
              System.out.println("More than 6 players are not allowed");
              return null;
          }
  
      }
  
      public void createDeck(List&lt;Player&gt; players){
          System.out.println("Number of Cards (24/36/52)");
          Scanner scanner = new Scanner(System.in);
          int numberOfCards = scanner.nextInt();
  
          Dealer newDeck = new Dealer(numberOfCards, numberOfPlayers);
          newDeck.shuffleDeck();
          newDeck.dealShuffledCardsToPlayers(players);
      }
  }
  </code></pre>
  
  <pre><code>public class Dealer {
      private Deck deck;
      private List&lt;Player&gt; players;
      private final int NUMBER_OF_CARDS;
  
      public Dealer(int numberOfCards, int numberOfPlayers) {
          this.deck = new Deck(numberOfCards);
          this.players = new ArrayList&lt;&gt;(numberOfPlayers);
          this.NUMBER_OF_CARDS = numberOfCards;
      }
  
      public void shuffleDeck(){
          Collections.shuffle(deck.getDeck());
      }
  
      public void dealShuffledCardsToPlayers(List&lt;Player&gt; players){
          for(Player player: players){
              for(int i= 0; i&lt;6; i++) {
                  player.setHand(deck.deal(6));
              }
          }
      }
  }
  </code></pre>
  
  <pre><code>public class Player {
      private String name;
      private int points;
      private List&lt;Card&gt; hand;
  
      public Player(String name) {
          this.name = name;
          this.points = 0;
          this.hand = new ArrayList&lt;&gt;();
      }
  
      public List&lt;Card&gt; getHand(){
          return hand;
      }
  
      public void setHand(List&lt;Card&gt; hand) {
          this.hand = hand;
  //        System.out.println(hand);
      }
  
  
      public void showHand(){
          for(int i=0; i&lt;this.hand.size(); i++){
              System.out.println(this.hand.get(i));
          }
      }
  
  }
  </code></pre>
  
  <pre><code>public class Deck{
      private List&lt;Card&gt; deck;
  //    private static final Random GENERATOR = new Random();
      public Deck (int numberOfCards) {
          deck = new ArrayList&lt;&gt;(numberOfCards);
  
          int count = 0;
  
          for (final Card.Suit suit : Card.Suit.values()) {
              for (final Card.Rank rank : Card.Rank.values()) {
                  deck.add(new Card(rank, suit));
                  count++;
              }
          }
      }
  
      public List&lt;Card&gt; getDeck(){
          return deck;
      }
  
      public List&lt;Card&gt; deal(int size){
          List&lt;Card&gt; hand = new ArrayList&lt;&gt;(size);
          hand.add(deck.remove(size));
          return hand;
      }
  }
  </code></pre>
  
  <p>Expected result is to deal 6 shuffled cards to players. Also please share your thoughts about what needs to be improved and what I have done wrong.</p>