Question: This should be done in java Java Card Simulator create a program with a main method and multiple classes that generate a deck of cards

This should be done in java

Java Card Simulator

create a program with a main method and multiple classes that generate a deck of cards with 2 players that will be dealt a certain hand of cards. Create a cardDeck class that contains all 52 possible cards of a regular deck and create a card class that will represents each card

In The main method

  • create an object of the cardDeck class. Does not need to be instantiated with parameters

  • Create 2 player objects with any names

  • Make a loop that gives five playing cards to both the players.

  • Print both Player objects in order to display the player's name and hand of cards

In the cardDeck class

  • The card deck has one instance variable - The card object array with room for 52 cards

  • Have the cardDeck class constructor fill the card deck array with the 52 unique cards. The ranks- 1,2,3,4,5,6,7,8,9,10, jack, queen, king, ace. Also include the suits- clubs, hearts, spades, and diamonds

  • Create a loop that goes through array ofsuits and ranks.

  • Create one card object for every suit and rank combination

  • Create a method for dealing the playing cards that subtracts a random card from the card deck and adds it to the hand of the player. This should return just one card object and should take no parameters. So the card cannot be drawn from the deck more than once, set the index to null

In playingCard class

  • make the ranks and suits as Strings

  • Each playing card will have two instance variables - a rank and suit

  • Each Cards rank and suit should set by constructor

  • Make a toString method of this class to display a card as "Four of Clubs" for example

Gambler class

  • A Gambler consists of a name. Each gambler also has 5 card object array to hold their cards

  • Have the gambler class constructor to set the gamblers name and make an array that is empty.

  • gambler class contains the addPlayingCard method that takes a playing card object as its parameter. This method should add cards to the gamblers hand which is an array of cards hand

  • Print gamblers name and the cards in their using toString

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!