First part of the
Gameclass for the game of Hearts:
The
Gameclass introduced in the text contained a deck and exactly two players. Improve that
Gameclass by including an array of type
Trick[]and a
numberOfTricksvariable that keeps track of the number of tricks played so far. Include a
finalinstance variable called
PLAYERS,which will be initialized in a constructor whose parameter value is the number of players participating in the game. Replace the individual
playerland
player2instance variables by instances in an array of type
Hand[].Include two
booleaninstance variables,
heartsand
queenOfSpades,whose values switch from
falseto
truewhenever the first heart or the queen of spades is played.
Write Java code that defines that part of the
Gameclass that includes the class heading, the instance variable declarations, and the one-parameter custom constructor whose parameter is the number of players. This constructor should instantiate a
Handarray with a length equal to the number of players. It should instantiate individual
Handobjects for each player, using a two-parameter
Handconstructor. The first parameter is the player number, starting with 0. The second parameter is the maximum number of cards that the player will receive, which depends on the total number of cards in the deck and the number of players. The game constructor should also instantiate a
Trickarray, but not populate it with any individual tricks.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.