import java.util.Scanner;
import javax.swing.JOptionPane;
public class Wukexing {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
int option = JOptionPane.YES_OPTION;
while (option == JOptionPane.YES_OPTION) {
int wo = 0, ta = 0, i = 1;
while (true) {
System.out.println("第" + i + "局输入如下:");
System.out
.println("你的输入是:scissor for 0,rock for 1,paper for 2");
int a = input.nextInt();
System.out
.println("计算机的输入是:scissor for 0,rock for 1,paper for 2");
System.out.println();
int b = (int) (Math.random() * 3); // 产生一个0~2的随机数并赋给计算
if (a - b == 1 || a - b == -2) {
wo++;
System.out.println("第" + i + "次,你赢了");
} else if (b - a == 1 || b - a == -2) {
ta++;
System.out.println("第" + i + "次,计算机赢了");
} else
System.out.println("第" + i + "次,平局了");
if (wo > 1 || ta > 1)
break;
i++;
}
if (wo > 1)
System.out.println("最终结果是你赢了");
else
System.out.println("最终结果是计算机赢了");
option = JOptionPane.showConfirmDialog(null, "Continue");
}
}
}
JOptionpane对话框游戏剪刀石头布
最新推荐文章于 2023-03-12 20:12:29 发布