Question: Write in java: core package AiPlayer class Card class Update class to include: 1. Method hashCode, it shall a. Return type int b. Receive no

Write in java:

core package

AiPlayer class

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. Concatenate member variable face and its hashcode

e. Concatenate member variable value and its hashcode

f. Concatenate member variable color and its hashcode

g. 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 custom 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

3

a. Return type is void

b. Receives no parameters

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 above 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

****Previous code****

//Game

package core;

import java.util.ArrayList; import java.util.Scanner;

/** * * @author roxsinegron */ public class Game { //Game

public Iterable list; public void createTeams(){ ArrayList list = new ArrayList<>(); Team teamOne=new Team(); Team teamTwo=new Team();

teamOne.setName("TeamOne"); teamTwo.setName("TeamTwo");

list.add(teamOne); list.add(teamTwo); Scanner scn=new Scanner(System.in); System.out.println("Enter human player name "); String name=scn.next(); //name of the player HumanPlayer plyr = new HumanPlayer(); plyr.setName(name); teamOne.add(plyr); String[] names={"Plr1","Plr2","Plr3"}; AiPlayer[] arr=new AiPlayer[3]; for(int i=0;i<3;i++){ arr[i]=new AiPlayer(); arr[i].setName(names[i]); }

teamOne.add(arr[0]); teamTwo.add(arr[1]); teamTwo.add(arr[2]); //game has two teams to choose from } public void outputTeams(){ for(Team a : list){ System.out.println("Team includes players : "+a.getName()); for(Player p : a.getListOfPlayers()){ System.out.println("Player : "+p.getName()); } } } }

//AiPlayer

package core;

/** * * @author roxsinegron */ // AiPlayer.java public class AiPlayer extends Player { public Card playCard() { return null; // implement as per player class. }

public void makeTrump() {

}

void setName(String name) { } }

//Deck

package core;

/** * * @author roxsinegron */ public class Deck { }

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!