Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

Recommended Textbook for

Oracle RMAN For Absolute Beginners

Authors: Darl Kuhn

1st Edition

1484207637, 9781484207635

More Books

Students also viewed these Databases questions

Question

HOW MANY TOTAL WORLD WAR?

Answered: 1 week ago

Question

Discuss the scope of financial management.

Answered: 1 week ago

Question

Discuss the goals of financial management.

Answered: 1 week ago

Question

LO29.1 Describe the business cycle and its primary phases.

Answered: 1 week ago