| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 582 人关注过本帖
标题:大家帮帮忙 帮忙翻译成java 这是c++
只看楼主 加入收藏
yujie_wu
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-5-7
结帖率:0
收藏
已结贴  问题点数:20 回复次数:4 
大家帮帮忙 帮忙翻译成java 这是c++
#include<iostream>
#include<string>
#include<math>
//Get a random number,indicating the chance and ranging from 1 to 100
int chance(){
return 1+rand()%100;
}
//Team's Class
class team{
private:
string name;
string location;
int    player;
int    score;
public:
void get_Name();
void get_Location();
bool pass();
bool shoot();
void print_Team_Status();
};
//methods of classes
//Get team's name
void team::get_Name(){
cin>>name;
}
//Get team's location
void team::get_Location(){
cin>>location;
}
//Pass the ball
//Return with a boolean indicating whethe the pass is successful
bool team::pass(){
bool success=(chance()<=50);
if(success)
if(player<3) player++;//if a striker(when player is 3) makes a successful  pass, the value of player won't change
else
player=0;
return success;
}
//Shoot
//Return with a boolean indicating whethe the shoot is successful
bool team::shoot(){
bool success;
swich(player){
case:1
success=(chance()<=10);
break;
case:2
success=(chance()<=10);
break;
case:3
success=(chance()<=10);
}
if(success) score++;
player=0;
return success;
}
//Print the status of the team
//The status includes location,name,score and which player is holding the ball if the team  has the ball
void team::print_Team_Status(){
cout<<location<<' '<<name<<" has "<<score<<" goals.";
switch(player)
{
case 1:
cout<<" Their Defender has the ball."
break;

case 2:
cout<<" Their Midfielder has the ball."
break;

case 3:
cout<<" Their Striker has the ball."
}
cout<<endl;
}

搜索更多相关主题的帖子: java 翻译 
2010-05-07 13:59
liubangchuan
该用户已被删除
收藏
得分:5 
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-07 18:05
wszahng
该用户已被删除
收藏
得分:5 
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-08 13:00
shyun
Rank: 1
等 级:新手上路
帖 子:7
专家分:5
注 册:2010-5-7
收藏
得分:5 
楼楼上牛人!
2010-05-08 16:32
bluesnowbird
Rank: 1
等 级:新手上路
帖 子:6
专家分:7
注 册:2010-5-8
收藏
得分:5 
牛人!!
2010-05-08 22:27
快速回复:大家帮帮忙 帮忙翻译成java 这是c++
数据加载中...
 
   



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

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