Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Card class Update class to include: Method hashCode, it shall Return type int Receive no parameters Include local variable hashCode of data type int initialized

Card class

Update class to include:

Method hashCode, it shall

Return type int

Receive no parameters

Include local variable hashCode of data type int initialized to the value of zero

Return the local variable hashCode

Method equals, it shall

Return type Boolean

Receive one parameter of data type Object

Check if the parameter is an instanceof class CardIf true

Explicitly convert the parameter to an instance of class Card

Return the result of comparing if the face, suit, and color match an existing object

Code example:

return (card.face.equals(this.face) &&

card.color.equals(this.color) &&

card.suit.equals(this.suit));

Else

Return false

Deck class

Update class to

Write a customer constructor that

Receives no parameters

Calls method generateDeck()

Calls method displayDeck()

Calls method shuffleDeck()

Calls method displayDeck()

Write method generateDeck so that

Return type is void

Receives no parameters

Instantiates the member variable of type Set calling the constructor for class HashSet

Loops through the values of enumeration FaceLoops through the values of enumeration Suit

Instantiates an instance of class Card

Sets the face value of the card

Sets the suit of the card

Determines the color of the card based on the suit and sets the color of the card

Verifies the instance of Card created is not contained in the HashSet of cards

If it does not exist, add the instance of class Card to the HashSet

Write method displayDeck so that

Return type is void

Receives no parameters

Iterates through the HashSet collection outputting to the console the face value, suit, and color of each card

Write method shuffleDeck so that

Instantiates an instance of class ArrayList, explicitly for data type of class Card passing the member variable of interface Set as an argument

Call static method Collections.shuffle passing the ArrayList from abouve as an argument

Reinstantiate the member variable of interface Set by calling the constructor for class HashSet passing the ArrayList above as an argument

Game class

Update class to

Update the custom constructor to call method generateDeck()

Add method generateDeck so that

Return type is void

Receives no parameters

Instantiates the member variable of class Deck

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

Students also viewed these Databases questions

Question

Organize and support your main points

Answered: 1 week ago

Question

Move smoothly from point to point

Answered: 1 week ago

Question

Outlining Your Speech?

Answered: 1 week ago