Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This should be done in java as simple as possible using objects, classes, methods ,loops and arrays. Create a program that deals 2 players five

This should be done in java as simple as possible using objects, classes, methods ,loops and arrays.

Create a program that deals 2 players five cards each from a normal deck of 52 playing cards

  • The ranks of the cards are1,2,3,4,5,6,7,8,9,10, jack, queen, king, ace and the suits are clubs, hearts, spades, and diamonds

Follow instructions below:

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 suits and ranks arrays.

  • 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.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Online Market Research Cost Effective Searching Of The Internet And Online Databases

Authors: John F. Lescher

1st Edition

0201489295, 978-0201489293

More Books

Students also viewed these Databases questions