| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2704 人关注过本帖
标题:已经试了无数遍,这个就是加不起来
取消只看楼主 加入收藏
mark191919
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-12-12
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
已经试了无数遍,这个就是加不起来
声明:本人中文退化。

package Assignments;

public class RockPaperScissorator {

    public static void main(String[] args) {
        // TODO Auto-generated method stub

        
        
        
        System.out.println("Welcome! Let’s Play Rock-Paper-Scissors!'");
        System.out.println("Remember:");
        System.out.println("Rock breaks Scissors, Paper covers Rock and Scissors cut Paper");
        System.out.println("");System.out.println("");System.out.println("");
        int p;
        do{
        int a,c,b;
        a=0;
        b=0;
        c=(int) (Math.random()*2+1);
        System.out.println("Ready?!");
        System.out.println("1. Rock");
        System.out.println("2. Paper");
        System.out.println("3. Scissors");
        System.out.println("Please choose your action: ");
        p=TextIO.getlnInt();
        do{
        if(p==1){
            if(c==1){System.out.println("Computer chose Rock!"); System.out.println("It’s a tie!"); a+=0;}
            if(c==2){System.out.println("Computer chose Scissors!");System.out.println("You win!");a+=1;}
            if(c==3){System.out.println("Computer chose Paper!");System.out.println("You lose!");a-=1;}
        }
        if(p==2){
            if(c==1){System.out.println("Computer chose Paper!'");System.out.println("It’s a tie!");a+=0;}
            if(c==2){System.out.println("Computer chose Rock!");System.out.println("You win!");a+=1;}
            if(c==3){System.out.println("Computer chose Scissors!");System.out.println("You lose!");a-=1;}
        }
        if(p==3){
            if(c==1){System.out.println("Computer chose Scissors!");System.out.println("It’s a tie!");a+=0;}
            if(c==2){System.out.println("Computer chose Paper!");System.out.println("You win!");a+=1;}
            if(c==3){System.out.println("Computer chose Rock!");System.out.println("You lose!");a-=1;}
                }}while(p<0);
        b+=1;   
        
        System.out.println("You have won "+a+" of "+b+" games.");
        }while(p%1==0||p>0);
    }

}


他最后呢应该是这个样子的:

Welcome! Let’s Play Rock-Paper-Scissors!
Remember:
Rock breaks Scissors, Paper covers Rock and Scissors cut Paper



Ready?!
1 – Rock
2 – Paper
3 – Scissors
0 - Exit
Please choose your action: 2

Computer chose Paper!
It’s a tie!
You have won 0 of 1 games.


Ready?!
1 – Rock
2 – Paper
3 – Scissors
0 - Exit
Please choose your action: 2

Computer chose Rock!
You win!
You have won 1 of 2 games.


Ready?!
1 – Rock
2 – Paper
3 – Scissors
0 - Exit
Please choose your action: 0

Goodbye!
You have won 1 of 2 games.

先别急,我还没加exit进去。。
我现在遇到的状况是这样的:
Welcome! Let’s Play Rock-Paper-Scissors!'
Remember:
Rock breaks Scissors, Paper covers Rock and Scissors cut Paper



Ready?!
1. Rock
2. Paper
3. Scissors
Please choose your action:
3
Computer chose Scissors!
It’s a tie!
You have won 0 of 1 games.
Ready?!
1. Rock
2. Paper
3. Scissors
Please choose your action:
1
Computer chose Rock!
It’s a tie!
You have won 0 of 1 games.
Ready?!
1. Rock
2. Paper
3. Scissors
Please choose your action:
2
Computer chose Rock!
You win!
You have won 1 of 1 games.
Ready?!
1. Rock
2. Paper
3. Scissors
Please choose your action:
2
Computer chose Rock!
You win!
You have won 1 of 1 games.

为毛一直是1啊。。。。。。。。。。。。。。
而且胜局也加不起来啊。。。。。。。。。。。。。
求解!!!!!!!!
搜索更多相关主题的帖子: Welcome package public method 中文 
2015-12-12 11:41
mark191919
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-12-12
收藏
得分:0 
为啥一个人也没有
2015-12-12 11:56
mark191919
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2015-12-12
收藏
得分:0 
。。。。。。。。。。。。。
2015-12-12 12:06
快速回复:已经试了无数遍,这个就是加不起来
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.012889 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved