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

Java Program (WAR CARD GAME) War is a card game for two players. A standard deck

ID: 3887189 • Letter: J

Question

Java Program (WAR CARD GAME)

War is a card game for two players.

A standard deck of 52 cards is dealt so that both players have 26 cards.

During each round of play (or "battle"), both players play a card from the top of their hand face up.

The player who plays the card of the higher rank wins both cards and places them at the bottom of his stack of cards.

If both cards played are of the same rank, then both players play three additional cards face down and then one more card face up (this is called a "war").

The player who wins the war by playing the higher card wins all ten cards.

If the ranks are still the same, additional wars are played until one player wins the turn.

If either player runs out of cards to play, he loses the game.

You will use only ArrayLists to store the cards in this program. This means cards cannot be stored in arrays.

Sample output might look like this:

Think of a Card as an object with properties (rank, suit, etc.)

Think of a Deck of Cards as a Collection of Objects

Think of the remaining objects: Hand, Discard Pile, etc. as a collection of objects

You may find methods in the Collections class that will help with some of the functionality needed in this project.

Explanation / Answer

import java.util.*;

import java.util.ArrayList;

public class cardWar{

        Deck.add( 2);

Deck.add(3);

Deck.add(4);

Deck.add(5);

Deck.add(6);

Deck.add(7);

Deck.add(8);

Deck.add(9);

Deck.add(10);

Deck.add(11);

Deck.add(12);

Deck.add(13);

Deck.add(14);

Deck.add(2);

Deck.add(3);

Deck.add(4);

Deck.add(5);

Deck.add(6);

Deck.add(7);

Deck.add(8);

Deck.add(9);

Deck.add(10);

Deck.add(11);

Deck.add(12);

Deck.add(13);

Deck.add(14);

Deck.add( 2);

Deck.add(3);

Deck.add(4);

Deck.add(5);

Deck.add(6);

Deck.add(7);

Deck.add(8);

Deck.add(9);

Deck.add(10);

Deck.add(11);

Deck.add(12);

Deck.add(13);

Deck.add(14);

Deck.add(2);

Deck.add(3);

Deck.add(4);

Deck.add(5);

Deck.add(6);

Deck.add(7);

Deck.add(8);

Deck.add(9);

Deck.add(10);

Deck.add(11);

Deck.add(12);

Deck.add(13);

Deck.add(14);

Collections.shuffle(Deck);

int size=Deck.size();

int size1;

size1=size/2 +1;

faceofflist.remove(get(l));

}

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