Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Steven Lam
- * April 24, 2013
- * Purpose: To take User inputs and run the corresponding choice from the main menu and to play the War Game
- * Input: Choice from the main menu and yes/no if User wants to play again
- * Output: Corresponding choice from the main menu and the War Game
- */
- 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();
- 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("-----------------------");
- 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();
- System.out.println("My Score is " + d.Comp);
- System.out.println();
- if (d.User > d.Comp)
- {
- System.out.println("You Won!");
- }
- else if (d.User == d.Comp)
- {
- System.out.println("It is a Tie!");
- }
- else if (d.User < d.Comp)
- {
- System.out.println("I Won!");
- }
- System.out.println();
- d.User=0;
- d.Comp=0;
- System.out.println("Wanna Play Again? (Yes: 1 / No: 2)");
- WAR=keyboard.nextInt();
- }
- d.ShowMenu();
- break;
- case 5:
- System.out.println("5");
- menu=1;
- break;
- default: System.out.println("Sorry, That's Not Part Of the Menu. Select An Option From The Menu");
- }
- }
- System.out.println("Thank You For Playing WAR!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement