/**
* 游戏:石头,剪刀,布。
* 程序提示用户随机产生一个数,这个数是0、1或2,分别表示石头、剪刀和布。
* 提示用户输入值0、1或2:
* 显示一个消息,表明用户和计算机是谁赢了游戏,谁赢了游戏,或者是达成了平手。
*/
package Test;
import java.util.Scanner;
public class T317Scanner {
public static void main(String[] args) {
int num = (int)(Math.random() * 3);
System.out.println(num);
Scanner input = new Scanner(System.in);
System.out.print("Scissor (0), Rock (1), Paper (2): ");
int guess = input.nextInt();
if (guess == num)
System.out.println("The computer is paper. You are paper too. It is a draw!");
else
System.out.println((guess == 0 && num == 1 || guess == 1 && num == 2 || guess == 2 && num == 0)
? "The computer is scissor. You are rock. You won!"
: "You are scissor. The computer is rock. The computer won!");
}
}