当前位置: 代码迷 >> Java相关 >> 大家帮帮忙 帮忙翻译成java 这是c++
  详细解决方案

大家帮帮忙 帮忙翻译成java 这是c++

热度:140   发布时间:2010-05-07 13:59:19.0
大家帮帮忙 帮忙翻译成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 10:05:06
wszahng
该用户已被删除
  得分:5 
提示: 作者被禁止或删除 内容自动屏蔽
2010-05-08 05:00:18
shyun

等 级:新手上路
帖 子:7
专家分:5
注 册:2010-5-7
  得分:5 
楼楼上牛人!

----------------解决方案--------------------------------------------------------
牛人!!
----------------解决方案--------------------------------------------------------
  相关解决方案