12345678910111213141516171819202122232425262728293031323334353637 |
- package com.sf;
- import java.util.Scanner;
- public class MethodBlogsTest {
- /**
- * 猜拳游戏 1 石头 2 剪刀 3 布
- */
- public static void main(String[] args) {
- System.out.println("游戏开始啦");
- Scanner scanner = new Scanner(System.in);
- int comIntegral = 0;
- int playIntegral = 0;
- while (comIntegral <5 | playIntegral < 5){
- //随机生成电脑数
- int com = (int) (Math.random()*3+1);
- //人的数
- int player = scanner.nextInt();
- if(player == 886){
- break;
- }
- if(player >0 & player <4){
- if(player != com){
- if(player - com == -1 | player - com == 2){
- playIntegral +=1;
- }else {
- comIntegral +=1;
- }
- }else {
- System.out.println("默契");
- }
- }else {
- System.out.println("输入有误");
- }
- }
- }
- }
|