Question: Object oriented java using eclipse: I need help programming the war game using the deck.java and card.java classes(code displayed below) using eclipse following the steps
Object oriented java using eclipse:
I need help programming the war game using the deck.java and card.java classes(code displayed below) using eclipse following the steps below. The output of the code should also look like the sample output(also displayed below)


deck.java:
package assignment3; // change to your package import java.util.Random; // import Random class
public class Deck { private Card [ ] deck = new Card [52]; // array of 52 Card references private int topCard = 0; // top card of deck public Deck ( ) // POST: deck is initialized by suit and rank { for (int k=0; k
for (int k = 0; k
public Card deal ( ) // POST: return the top card { topCard++; // increase top card marker return deck[topCard-1]; // return previous top card } // code could be shortened to: return deck[topCard++] using postfix ++ operator }
Card.java:
package assignment3; // change to your package name
public class Card { private int cardNumber; // card number 0 .. 51 public Card ( ) // POST: card number set to 0 (2 Diamonds) { cardNumber = 0; }
public Card (int n) // PRE: 0 Part II: (80 pts In this problem you will use the Deck class to play a simplified version of the card game War. A player wins when all cards are taken from the other player. We will do a shorter variation where one only pass is made through the original hands. When all 26 cards have been processed the winner is the player with the larger win pile or it is a draw. In a real game, once the hand is empty the player uses the win pile as the hand. Rules of War: Each player begins with 26 cards from the shuffled deck. During a round each player displays the top card from their hand. The player with the higher card takes both cards and puts them in a win pile If the cards are the same rank a War loop begins. Each player displays five cards from the top of their hand. The player with the higher fifth card takes all cards and puts them in their win pile. If there is a tie another War begins and the winner of that takes all cards. So continues the War loop If a player cannot place five cards from the hand, as many as possible are placed and the top card is used. Submit Turn in neatly formatted source code of WarGame.java and TestWarGame.java printed from Eclipse in landscape orientation and output of a game showing hands and win piles each round with at least one win for each player and one war example. The output can be printed landscaped, no word wrap accepted. See attached sample; your output should display similar information for each round. Use your name in the output. Notes: 1. The Deck class illustrated in lecture should be used. Code for Deck.java and Card.java is available on First Class. You must use arrays in the WarGame class; no higher level data structures permitted. Command option
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
