Java Reference
In-Depth Information
System.out.println("Paper");
break;
case SCISSORS:
System.out.println("Scissors");
break;
default:
System.out.println("Invalid");
}
}
private static void playHands(int yourHand, int
myHand) {
// Rock = 1
// Paper = 2
// Scissors = 3
// Hand combinations:
// 1,1; 2,2; 3,3 => Draw
// 1,2 => sum = 3 => Paper
// 1,3 => sum = 4 => Rock
// 2,3 => sum = 5 => Scissors
//
switch ((yourHand == myHand) ? 0 : (yourHand
+ myHand)) {
case 0:
System.out.println("Draw!");
break;
case 3:
System.out.print("Paper beats Rock. ");
printWinner(yourHand, 2);
break;
case 4:
System.out.print("Rock beats Scissors. ");
printWinner(yourHand, 1);
break;
case 5:
System.out.print("Scissors beats Paper.
Search WWH ::




Custom Search