GameRockPaperScissors

- import java.util public class cfw static Scanner console = new Scanner(System.in public static void main(String args cfw/Step 1 int gameCount/to

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; i public class GameRockPaperScissors { static Scanner console = new Scanner(System.in); public static void main(String[] args) { //Step 1 int gameCount; //to count the number of //games played int winCount1; //to count the number of //games won by player 1 int winCount2; //to count the number of //games won by player 2 int gameWinner; char response; //to get the user's response //to play the game char selection1; char selection2; RockPaperScissors play1; //player1's selection RockPaperScissors play2; //player2's selection //Initialize the variables; Step 2 gameCount = 0; winCount1 = 0; winCount2 = 0; displayRules(); //Step 3 System.out.print("Enter Y/y to play " + "the game: "); //Step 4 response = console.nextLine().charAt(0); //Step 5 System.out.println(); while (response == 'Y' || response == 'y') //Step 6 { System.out.print("Player 1 enter " + "your choice: "); //Step 6a selection1 = console.nextLine().charAt(0); //Step 6b System.out.println(); System.out.print("Player 2 enter " + "your choice: "); //Step 6c selection2 = console.nextLine().charAt(0);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/17/2011 for the course COMP 2301 taught by Professor Staff during the Spring '10 term at Kennesaw.

Page1 / 4

- import java.util public class cfw static Scanner console = new Scanner(System.in public static void main(String args cfw/Step 1 int gameCount/to

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online