Question
Java 'Array of references card game. In this project you will create a solution designed to play a simplified version of the card game WAR
Java 'Array of references card game. In this project you will create a solution designed to play a simplified version of the card game "WAR" . we will use simplified rules of the game. Create a deck of cards. Shuffle the deck . Deal the deck into two-faced piles of 26 cards each. Turn over the top card from each players pile and display the card using the toString() method. Whoever onws the higher of the two cards wins possesion of both the cards and places them in their "wiin" pile. If the two cards turn up with the same value( use the getValue() method. each player then puts an additional card into the center pile and turns over a second card. The owner of the higher of this newly turned over card wins all the cards in that play( the two original and the four additional). If tthis results in another tie, the same procedure is followed. Once the two original piles are depleted, count the number of the cards owned by each player. The player with the most number of cards wins the game. How to get Started Create a class called Card. The card has three fields; a value , a suit and a face. The card class has a constructor that takes three of the fields Write three get methods() to return the values of each of the fields. Write a toString method. Write a compareTo() method that uses the value of the card to determine the ordering. For values, a face of "two" has a value of 2. a face of "three" has a value of 3 ...... For this game Jack, Queen , and King are valued in ascending order and Ace has the highest value. Write a equals () method that returns true if argument Card has the same suit and the same face as the invoking card. Create a class called Deck. A deck has two fieds- an array of Card references and an index to hold the subscript of the top card. The deck class will have only one constructor, which will create the array. Try to think of a way to code this without writing 52 statements.( not required). The deck class also has a method getTopCard() which returns a reference to the Card that is at the top of the array. Write a method called shuffle () which shuffles the array of Cards. To shuffle, generate random numbers and use these to exchange array elements. Exchange 1000 times in this method. If you are unsure of how to generate random number after reading the Java API documentation on the Random class please look in your notes. Create the Driver class- call it Game This is where your game logic will go. As a hint, you will need to create an instance of the deck class and call its shuffle() method. Deal the cards from the Deck for each player(two more arrays) Draw the cards, show the card and determine who wins the two cards or if a war is needed Once a game is won, allow the user to decide if he/she wants to play another game. keep running a total of the number of games won by the two players.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started