Java Reference
In-Depth Information
To describe the objects ROCK , PAPER , and SCISSORS , we define the following enum
type:
public enum RockPaperScissors
{
ROCK ("Rock crushes scissors."),
PAPER ("Paper covers rock."),
SCISSORS ("Scissors cuts paper.");
private String mgs;
private RockPaperScissors()
{
mgs = "";
}
private RockPaperScissors(String str)
{
mgs = str;
}
public String getMessage()
{
return mgs;
}
}
It is clear that you need the following variables in the method main :
Variables
(Method
main )
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
This program is divided into six methods, which the following sections describe in
detail.
 
Search WWH ::




Custom Search