import javax.swing.JPanel;
我要创建Player类的一个基本的“冒险”的游戏,我们正在为Java类中的一组项目。 Eclipse告诉我,我的get和set方法(getStr,getAgi等)都需要用分号来完成块。但我知道这是不对的。一般的帮助或建议?问题与我的Java项目
public class playerChars extends JPanel{
private int str, agi, intell, hitP;
private String wep, arm;
die sixSidedDie = new die(6);
{
public int getStr(str)
{
str = sixSidedDie.getValue();
}
public int getAgi(agi)
{
agi = sixSidedDie.getValue();
}
public int roll(intell)
{
intell = sixSidedDie.getValue();
}
public int getHitP(hitP)
{
hitP = sixSidedDie.getValue();
}
}
public static int setQuant(int quantity)
{
int quant;
quant = quantity;
}
public String getWep()
{
return wep;
}
public String setWep(String weapon)
{
this.wep = weapon;
}
public String getArm()
{
String armor;
return armor;
}
public String setArm(String armor)
{
this.arm = armor;
}
public int setPot(int potion)
{
int pot;
pot = potion;
}
public int getPot()
{
int potion;
return potion;
}
}
你应该先学习基本的java。这甚至没有适当的格式。 –
你能给我任何关于正确格式的建议吗? – rythmshifter
这是一个基本的Java基础知识问题......你显然根本不知道任何Java,慢慢来吧。 –