首页 新闻 赞助 找找看

求完整版的游戏代码

0
[已关闭问题] 关闭于 2013-12-31 11:13
 1 import java.util.*;
 2 public class test{
 3     public static void main(String[] args){
 4         Scanner in=new Scanner(System.in);
 5         int person;
 6         System.out.println("---------猜拳游戏--------");
 7         //while(!=EOF)
 8             {
 9                 System.out.println("请出拳(1.剪刀 2.石头 3.布)");
10             }
11         person=in.nextInt();
12         try{
13             if(person>3&&person<1)
14             System.out.println("请出拳(1.剪刀 2.石头 3.布)");
15         }
16         catch(Exception e)
17         {
18             System.out.println("请出拳(1.剪刀 2.石头 3.布)");
19         }
20         finally
21         {
22             System.out.println("输入有误,请重新输入:");
23             
24         }
25         person=in.nextInt();
26         int computer=(int)(Math.random()*3)+1;
27         if(person==computer){
28             System.out.println("你出的是:"+person+"电脑出的是:"+computer+"--平局");
29         }else if(person==1&&computer==2||person==2&&computer==3||person==3&&computer==1){
30             System.out.println("你出的是:"+person+"电脑出的是:"+computer+"-_-你输了");
31         }else if(person==1&&computer==3||person==2&&computer==1||person==3&&computer==2){
32             System.out.println("你出的是:"+person+"电脑出的是:"+computer+"^_^你赢了");
33         }
34         
35     }
36 }
问题补充:

[url=http://www.51zxw.net/study.asp?vip=4525296]51自学网-专业培训老师录制的视频教程,让学习变得很轻松[/url]

轩辕恒辰的主页 轩辕恒辰 | 菜鸟二级 | 园豆:205
提问于:2013-12-11 16:40
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册