diff --git a/bin/cards/maumau/model/CardHandler.class b/bin/cards/maumau/model/CardHandler.class index 24778c3..e79c97e 100644 Binary files a/bin/cards/maumau/model/CardHandler.class and b/bin/cards/maumau/model/CardHandler.class differ diff --git a/src/cards/maumau/model/CardHandler.java b/src/cards/maumau/model/CardHandler.java index c69a174..b0cfe80 100644 --- a/src/cards/maumau/model/CardHandler.java +++ b/src/cards/maumau/model/CardHandler.java @@ -71,9 +71,38 @@ class CardHandler { /** * Deals cards to all players. + * @throws Exception when there are not enough cards to satisfy starting conditions */ - void dealCards() { - //TODO implement + void dealCards() throws Exception { + + // get List of players + List players = game.getPlayers(); + + + //checks if there are enough cards to be dealt + int totalCardsNeeded = players.size() * numCardsPerPlayer + 1; + + if (totalCardsNeeded > drawPile.size() ){ + throw new Exception("Not enough cards to deal!"); + } + + + for (int i = 0; i < numCardsPerPlayer; i++) { + + for (int j = 0; j < players.size(); j++) { + + // get the current player + Player currPlayer = players.get(j); + + //execute drawCards as currPlayer to draw 1 card + currPlayer.drawCards(1); + + + } + } + + // Put the starting card on the discard Pile + discard(drawCard()); } /**