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; ArrayListcards; 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 ArrayListgetCards(){}
//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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started