| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 389 人关注过本帖
标题:急!!!!大家帮帮忙 把这个c++翻译成java
只看楼主 加入收藏
yujie_wu
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-5-7
结帖率:0
收藏
 问题点数:0 回复次数:2 
急!!!!大家帮帮忙 把这个c++翻译成java
#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 14:00
yujie_wu
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-5-7
收藏
得分:0 
   沙发...
2010-05-07 14:25
yujie_wu
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2010-5-7
收藏
得分:0 
  沙发
2010-05-07 14:25
快速回复:急!!!!大家帮帮忙 把这个c++翻译成java
数据加载中...
 
   



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

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