This assignment is about card game called WAR that has 4 classes the.docx - This assignment is about card game called WAR that has 4 classes the

This assignment is about card game called WAR that has 4 classes the.docx

This preview shows page 1 - 5 out of 13 pages.

Image of page 1
This assignment is about card game called WAR that has 4 classes the main,Card,CardDeck,and Hand. I am struggling at hand class which required public Hand()// constructor of the object that hold the players cards. public void displayHand()// display the hand public void take(Card c )// takes a card that is dealt public int value()// retuns the value of the hand could you please help me here is the code in java : import java.util.Scanner; public class main { public static void main(String[] args) �� { Scanner keyboard = new Scanner(System.in); int Choice; int menu=0, WAR=1; CardDeck d = new CardDeck(); System.out.println("Welcome to the War Game"); d.ShowMenu(); while (menu==0){ Choice = keyboard.nextInt(); WAR=1; d.User=0; d.Comp=0; switch (Choice) { case 1: d = new CardDeck();
Image of page 2
System.out.println("You Have A New Card Deck!"); d.ShowMenu(); break; case 2: System.out.println("-----------------------------------"); System.out.println("Here Are All The Cards In The Deck!"); System.out.println("-----------------------------------"); for (int k = 0; k<52;k++) { d.displayCardAt(k); } d.ShowMenu(); break; case 3: d.shuffle(); System.out.println("Your Deck Has Been Shuffled!"); d.ShowMenu(); break; case 4: while(WAR==1) { System.out.println("----------------------------------"); System.out.println("Get Ready To Play Two-Card WAR!!!!"); System.out.println("----------------------------------"); System.out.println("There are "+d.cardsLeft()+" left in the deck."); System.out.println("...dealing..."); System.out.println("-----------------------");
Image of page 3
System.out.println("Here Are Your Two Cards"); System.out.println("-----------------------"); d.Deal(); d.Deal(); System.out.println("---------------------"); System.out.println("Here Are My Two Cards"); System.out.println("---------------------"); d.CompDeal(); d.CompDeal(); System.out.println(); System.out.println("Your Score is " + d.User); System.out.println();
Image of page 4
Image of page 5

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture