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

Need help with this JAVA assignment, PLEASE PLEASE look at the question carefull

ID: 3859365 • Letter: N

Question

Need help with this JAVA assignment, PLEASE PLEASE look at the question carefully, need three classes and the output format shuld be the same as the sample output. Need it ASAP, thank you.

You will write an implementation of a simple card game called War. Details of the game's rules can be found here: http://www.bicyclecards.com/how-to-play/war/ This game uses a "standard" deck of playing cards, and involves two players. Each player is dealt half of a randomly shuffled deck (so 26 cards each). During each turn, both players simultaneously flip the top card of their deck. The player who flips the highest value card wins the turn, and "captures" both cards by adding them to the bottom of their deck. If both players flip over cards with the same value, then a "war" begins: each player takes the next two cards from their deck, flipping over one and leaving the second face-down. The flipped cards are compared, and the highest value of these cards determines the winner, who now takes the "war pile" all six cards). If these are also the same value, then the war continues; both players continue drawing two cards from their deck and flipping only the first one to compare values. The ultimate winner takes all cards in the "war pile". After a war, play resumes as normal by flipping and comparing only one card each at a time. Your gameshouldthre class Card,Deck,and Demo. Your game should use three class: Card, Deck, and Demo

Explanation / Answer

To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package wargame;

/**
*
* @author Akshay Bisht
*/
import java.util.ArrayList;   
import java.util.Random;
import java.util.List;
import java.util.Collections;   
import java.util.LinkedList;

public class WCG {
public static void main(String[] args) {
  
List<CRD> cd = new ArrayList<CRD>();
  
for(int io=0; io<4; io++){
for(int qp=2; qp<15; qp++){   
cd.add(new CRD(io,qp));
}
}
  
Collections.shuffle(cd, new Random());
  
LinkedList<CRD> dck = new LinkedList<CRD>();
LinkedList<CRD> dck1 = new LinkedList<CRD>();
  
dck.addAll(cd.subList(0, 25));   
dck1.addAll(cd.subList(26, cd.size()));
  
while(true){
CRD pCrd = dck.pop();
CRD pCrd1 = dck1.pop();
  
System.out.println("Player 1 plays card is " + pCrd.toString());
System.out.println("Player 2 plays card is " + pCrd1.toString());
  
if(pCrd.getCRD() > pCrd1.getCRD()){//if player 1 win
dck.addLast(pCrd);
dck.addLast(pCrd1);
System.out.println("PLayer 1 wins the round");
}

else if(pCrd.getCRD() < pCrd1.getCRD()){//if player 2 win
dck1.addLast(pCrd);   
dck1.addLast(pCrd1);
System.out.println("PLayer 2 wins the round");
}
  
else {
System.out.println("War");
  
List<CRD> w1 = new ArrayList<CRD>();
List<CRD> w2 = new ArrayList<CRD>();
  
for(int io=0; io<3; io++){
if(dck.size() == 0 || dck1.size() == 0 ){
break;
}
  
System.out.println("War card for player1 is xx War card for player2 is xx");

w1.add(dck.pop());
w2.add(dck1.pop());
}
  
if(w1.size() == 3 && w2.size() == 3 ){
System.out.println("War card for player1 is " + w1.get(0).toString());
System.out.println("War card for player2 is " + w2.get(0).toString());
if(w1.get(2).getCRD() > w2.get(2).getCRD()){
dck.addAll(w1);
dck.addAll(w2);
System.out.println("Player 1 wins the war round");
}
else{
dck1.addAll(w1);
dck1.addAll(w2);
System.out.println("Player 2 wins the war round");
}
}
  
}
  
if(dck.size() == 0 ){
System.out.println("game over Player 1 wins the game");
break;
}
else if(dck1.size() == 0){
System.out.println("game over Player 2 wins the game");
break;
}
}

}
}

CRD.java

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package wargame;

/**
*
* @author Akshay Bisht
*/
class CRD {
private int grades;
private int suites;
  
  
public CRD(int suites, int grades){
this.grades = grades;
this.suites = suites;
}
  
public int getCRD(){
return grades;
}
  
public void setCRD(int grades){
this.grades = grades;
}
  
@Override
public String toString(){

StringBuilder dispCRD = new StringBuilder();
  
switch(grades){
case 11:
dispCRD.append("Jack");
break;
case 12:
dispCRD.append("Queen");
break;
case 13:
dispCRD.append("King");
break;
case 14:
dispCRD.append("Ace");
break;
default:
dispCRD.append(grades);
break;
}
  
dispCRD.append(" of ");
  
switch(suites){
case 0:
dispCRD.append("Spades");
break;
case 1:
dispCRD.append("Hearts");
break;
case 2:
dispCRD.append("Clubs");
break;
case 3:
dispCRD.append("Diamonds");
break;
default:
break;
}
  
return dispCRD.toString();
}
  
}

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