Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hello, I need to follow instructions made by a teacher. I am a novice programmer

ID: 3722268 • Letter: H

Question

Hello, I need to follow instructions made by a teacher. I am a novice programmer and need help finding my errors. By a novice, I mean absolutely bad a coding. I am an art major so don't make me feel too stupid. Here are the instructions:

Card class

Update class to include:

1. Method hashCode, it shall

a. Return type int

b. Receive no parameters

c. Include local variable hashCode of data type int initialized to

the value of zero

d. Return the local variable hashCode

2. Method equals, it shall

a. Return type Boolean

b. Receive one parameter of data type Object

c. Check if the parameter is an instanceof class Card

i. If true

1. Explicitly convert the parameter to an instance

of class Card

2. Return the result of comparing if the face, suit,

and color match an existing object

3. Code example:

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

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

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

ii. Else

1. Return false

Deck class

Update class to

1. Write a customer constructor that

a. Receives no parameters

b. Calls method generateDeck()

c. Calls method displayDeck()

d. Calls method shuffleDeck()

e. Calls method displayDeck()

2. Write method generateDeck so that

a. Return type is void

b. Receives no parameters

3

c. Instantiates the member variable of type Set calling the

constructor for class HashSet

d. Loops through the values of enumeration Face

i. Loops through the values of enumeration Suit

1. Instantiates an instance of class Card

2. Sets the face value of the card

3. Sets the suit of the card

4. Determines the color of the card based on the

suit and sets the color of the card

5. Verifies the instance of Card created is not

contained in the HashSet of cards

a. If it does not exist, add the instance of

class Card to the HashSet

3. Write method displayDeck so that

a. Return type is void

b. Receives no parameters

c. Iterates through the HashSet collection outputting to the

console the face value, suit, and color of each card

4. Write method shuffleDeck so that

a. Instantiates an instance of class ArrayList, explicitly for data

type of class Card passing the member variable of interface

Set as an argument

b. Call static method Collections.shuffle passing the ArrayList

from abouve as an argument

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

1. Update the custom constructor to call method generateDeck()

2. Add method generateDeck so that

a. Return type is void

b. Receives no parameters

c. Instantiates the member variable of class Deck

Here are my code screenshots for Card class:

My Deck Class screenshots below:

Game class code screenshots:

This is the output I need to get:

My output is not displaying the last two screenshots. I have no idea why plus I am getting errors for methods not being in use. I am really struggling and appreciate any help even if the solution is simple. I just want to make sure I am doing things right.

package core; edu thor Matth /Explicitly importa each enumeration from Conatants imgort constants.Constants.Coloi ingort constants.Conszants.ui: public class card //added qerg and 3e:rg for he nemor varib1 below ecce ertorn the face public Face gtPace) retuin Eae Ereturn the auit public Suit getSait) i

Explanation / Answer

In the Deck Class write add this constructor :

public Deck(){

generateDeck();

displayDeck();

shuffleDeck();

displayDeck();

}

and in Game Class in generateDeck Method you did a small mistake correct it as : --------

private void generateDeck(){

deck = new Deck();

//not Deck deck = new Deck(); This code creates a new local variable which has the scope of only generateDeck() //method so initialize the class variable deck not create a local variable

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote