【发布时间】:2013-11-24 03:07:01
【问题描述】:
This 是我的任务。
public class Fighter {
public static void main(String[] args){
String name;
int hitPoints;
int defenseLevel;
int attackSpeed;
Scanner input=new Scanner(System.in);
public static void hitPoints(){
int hitPoints;
do{
Scanner input=new Scanner(System.in);
System.out.println("What is the hit points for the fighter");
hitPoints=input.nextInt();
return hitPoints;
}while (hitPoints<=50);
return 0;
}
}
我很确定循环它是完全错误的。我收到一个错误Syntax error on token "void", @ expected"。
我还尝试了不同的类型,例如int 和double。没有骰子。
作业说只使用一种 void 方法:
在 Fighter 类中编写两个方法;
public void input() public boolean attack(Fighter opponent)
但是,我不知道如何使用 1,所以我打算使用 4 或 5。
【问题讨论】:
标签: java methods static-methods void return-type