Java: Poker, deal a card [closed]

This is happening because you have two decks, not one.

public static void main(String[] args) {
   Deck deck = new Deck(); // deck 1
   Pile pile = new Pile(); 
   Game game = new Game(); // contains another deck, deck 2
   deck.shuffleCards(); // deck 1 is now shuffled

   System.out.println("\nLogic.CardNow: " + game.pickNextCard() +"\n"); // deck 2 (NOT SHUFFLED)
}

You need to either have game use your external (shuffled) deck, or you need to shuffle the deck that is inside of game.

The easiest option would be to update your initGame method to shuffle your deck:

public void initNewGame(){
    deck = new Deck();
    deck.fill();
    deck.shuffleCards(); // shuffle your deck
    pile.clear();
}

Leave a Comment