Question: Array Stack - Card Game Program Specifications: Now that we have a baseline understanding of abstract data types, we will be exploring a very common
Array Stack - Card Game
Program Specifications: Now that we have a baseline understanding of abstract data types, we will be exploring a very common data structure - the stack. Stacks are essential in understanding how computers work; the call stack is the foundation of how computer programs run.
The stack ADT can also be leveraged to greatly simplify any program that requires a collection of items where operations only occur on one end. It is a great ADT choice for writing simple card games.
Program a simple game that shuffles a deck of 52 cards and hands them out to two players randomly (26 each). Write a simulation of the card game, where, at each turn, both players take the card from the top of their pile and the player with the higher card wins that round. The winner of that round takes both cards and adds it to a stack of won cards.
In essence, there are four stacks. Each player has one stack of cards they are playing with and one stack of cards they have won. There are 26 rounds, since each player has a full stack of cards. At the end of the game, the player with the most cards in their won pile wins.
Notes:
The deck of cards can simply hold an integer between 0 and 51. The higher number wins. Dont worry about implementing suits like spades, hearts, etc.
To Do:
In ArrayStack.java Implement push(), pop(), peek(), length(), isFull(), and toString() methods
In Game.java Design and implement the game play logic
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
