Question: Java Code: War Card Game. I need help with this code. This is the Deck or Pile Class in the War Game. I need help

Java Code: War Card Game.

I need help with this code. This is the Deck or Pile Class in the War Game. I need help with it.

public class Pile { String name; ArrayList cards; static Random rng; public Pile(String name) { this.name = name; this.cards = new ArrayList<>(); } 
public static void setSeed(long seed){}

// Create and set the seed for the random number generator. First create the static object using the default constructor, and next call setSeed() on it and pass in the seed number.

public void shuffle(){ Collections.shuffle(this.cards); }

// Shuffle the cards and set them all to face down. It displays the following to standard output: "Shuffling {name} pile". Where {name} is the name of the pile. To shuffle an array list of cards you can do the following:

public void addCard(Card card){} 

//Add a card to the bottom of the pile

public ArrayList getCards(){}

//Returns the collection of cards in the pile's current state. Returns all cards

public Card drawCard(boolean faceUp){} // the card that was at the top of the pile. Get the next top card from the pile. First, check if the card at the top of the pile is face up public boolean hasCard(){} //returns whether there is a card in the pile or none. public void clear(){} //Remove all cards from the pile by clearing it out. public String toString(){}

// Returns a string representation of the pile in the format: "{name} pile: first-card second-card ..."

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!