import java.util.Scanner;

 public class Solution
 {
     public static void main(String[] args)
     {
         Scanner input = new Scanner(System.in);

         System.out.print("scissor(0), rock(1), paper(2): ");
         int playerValue = input.nextInt();

         input.close();

         int computerValue = (int)(Math.random() * 3);

         String player = "";
         if(playerValue == 0)
             player = "scissor";
         else if(playerValue == 1)
             player = "rock";
         else if(playerValue == 2)
             player = "paper";

         String computer = "";
         if(computerValue == 0)
             computer = "scissor";
         else if(computerValue == 1)
             computer = "rock";
         else if(computerValue == 2)
             computer = "paper";

         if(playerValue == computerValue)
             System.out.println("The computer is " + computer + ". You are " + player + " too. It is a draw.");
         else
             System.out.print("The computer is " + computer + ". You are " + player + ". ");

         if(playerValue == 0 && computerValue == 1 || playerValue == 1 && computerValue == 2 ||
             playerValue == 2 && computerValue == 0)
             System.out.println("Computer win");
         if(playerValue == 1 && computerValue == 0 || playerValue == 2 && computerValue == 1 ||
             playerValue == 0 && computerValue == 2)
             System.out.println("You win");
     }
 }

最新文章

  1. [转]关于typedef的用法总结
  2. C# Retry重试操作解决方案(附源码)
  3. Hibernate getCurrentSession()和openSession()的区别
  4. 4.1 spring-alias 标签的解析;
  5. python:UnicodeEncodeError
  6. VS2008试用版到期解决办法
  7. document.readystate
  8. 【HDU1856】More is better(并查集基础题)
  9. 【Spring源码分析】AOP源码解析(下篇)
  10. java list 去重
  11. django中的中间件机制和执行顺序
  12. Linux中Nginx安装与配置详解
  13. Java方法containsAll学习
  14. thinkphp5开发的网站出现”No input file specified”(php版本5.6.27)
  15. Google Chrome调试js代码,开发者工具之调试工具常用功能
  16. linux系统cpu使用100%的命令
  17. css实现栅格的方法
  18. JVM致命错误日志(hs_err_pid.log)解读
  19. 洛谷P2775 机器人路径规划问题
  20. 搭建配置cacti,采集信息监控

热门文章

  1. controller.pp 各组件的安装顺序
  2. IOS中将十进制色值转换成UIColor
  3. WPF中三种方法得到当前屏幕的宽和高
  4. mysql 导出导入数据库中所有数据
  5. 【BZOJ1823】 [JSOI2010]满汉全席
  6. 【实用技巧】文件MD5修改方法
  7. Android手势监听
  8. CodeChef A
  9. 在redhat6.4下安装 Oracle® Database 11g Release 2
  10. Hadoop源代码分析【IO专题】