preview

Public Static String Of Public

Decent Essays

public class War { public static String deck[] = new String[52]; public static String rank[]= {"2","3","4","5","6","7","8","9","10","Jack","Queen","King","Ace"}; public static String suits[]= {" of Spades"," of Hearts"," of Clubs"," of Diamonds"}; public static String player[] = new String[26]; //player deck public static String computer[] = new String [26]; //computer deck public static int pc=0; //player played card value public static int cc=0; //computer played card value public static int pw; //player winning pile public static int cw; //computer winning pile public static int s; //array counter public static void main(String[] args) { System.out.println("Welcome to War!"); deck(); shuffle(); deal(); s=0; do { System.out.printf("Player 's Card: " + player[s] + " Computer 's Card: " + computer[s] + " "); Value(); if ( pc != cc) { basicRound(); s++; } else { declareWar(); s=s+3; } }while (s cw) { System.out.printf("Player Wins!" + " "); } else { System.out.printf("Player Lost" + " "); } System.out.printf("Play Again or Exit?" + " "); } public static void deck() { for (int i = 0; i< deck.length; i++) { deck[i] = rank[i%13]+ suits[i/13]; } } public static void shuffle() { for (int i = 0; i < deck.length; i++) { int index = (int)(Math.random()*deck.length); String temp = deck[i]; deck[i] = deck[index]; deck[index] = temp; } } public static

Get Access