thanks for your help, hand comparison is working now.
now, i want to set how many rounds the player will play.
look at this..
private static void twoPlayer() {
int count;
out.print("How many rounds you wish to play? ");
count = in.nextInt();
out.print("\nPlayer 1 Name: ");
oneName = getName();
out.print("Player 2 Name: ");
twoName = getName();
for(int i=1;i<=count;i++) {
System.out.print(oneName + "'s Hand: ");
oneHand = getHand();
System.out.print(twoName + "'s Hand: ");
twoHand = getHand();
announceWinner(compareHand(oneHand, twoHand));
out.println();
}
}
my PROBLEM IS.. when i set the number of rounds, i get this output..
ROCK-PAPER-SCISSORS GAME
NOTE: hand input will loop until user(s) input(s) valid hand values
VALID HANDS: rock, paper, scissors
Select your option below:
[1] Player vs Player
[2] Player vs Computer 1
How many rounds you wish to play? 3
Player 1 Name: Player 2 Name: Player 1 Name: Player 2 Name:
Michael
's Hand: rock
Michael's Hand: scissors
ROCK wins over SCISSORS
wins.
scissors
's Hand: rock
Michael's Hand: rock
It's a tie.
's Hand: paper
Michael's Hand: rock
PAPER wins over ROCK
wins.
what happens is:
1. i enter number of rounds, say 3.
2. as i see from the output, out.print("\nPlayer 1 Name: "); oneName = getName(); out.print("Player 2 Name: "); twoName = getName(); seems to loop 3 TIMES ALSO.
3. i can set the player's name
BUT note that only the twoName (the player two) is set, oneName can't.
what i WANT TO SEE ON THE OUTPUT IS:
ROCK-PAPER-SCISSORS GAME
NOTE: hand input will loop until user(s) input(s) valid hand values
VALID HANDS: rock, paper, scissors
Select your option below:
[1] Player vs Player
[2] Player vs Computer 1
How many rounds you wish to play? 3
Player 1 Name: Michael
Player 2 Name: John
Michael's Hand: rock
John's Hand: scissors
ROCK wins over SCISSORS
Michael wins.
Michael's Hand: rock
John's Hand: rock
It's a tie.
Michael's Hand: paper
John's Hand: rock
PAPER wins over ROCK
Michael wins.
so:
1. i enter number of rounds, say 3.
2. i enter the names of the players.
3. names appear properly on the hand input. (eg.
Michael's Hand: rock)
i'm wondering why this part
out.print("\nPlayer 1 Name: ");
oneName = getName();
out.print("Player 2 Name: ");
twoName = getName();
seems to loop also three times. it's odd because this statements aren't inside the for loop.
help!