java为类添加GUI
我想知道如何将GUI添加到我的程序中。我已经开始用Blue J创建一个java程序,该程序的第一个类是一个被其他类扩展的类
现在我也必须制作一个GUI,但据我所知,我只能在GUI扩展类框架时实现一个接口。问题是我想为我的类创建一个GUI,它也有实例变量,所以有解决办法吗?我可以让我的第一个类成为一个接口,而不需要对扩展做太多修改吗
代码:
public class Players /* Class name */
{
private int attack; /* Instance variables* */
private int defence;
private int jump;
public Players(int a, int d, int j) /* Constructor being defined */
{
int total = a + d + j;
if((total) == 100)
{
attack = a;
defence = d;
jump = j;
}
else
{
System.out.println("Make stats add to 100");
}
}
public Players()/* Default contructor if not user defined */
{
attack = 34;
defence = 33;
jump = 33;
}
public void addAttack(int a)
{
attack += a;
}
public void addDefence(int a)
{
defence += a;
}
public void addJump(int a)
{
jump += a;
}
public void getBasicStats()
{
System.out.println(attack + " " + defence + " " + jump);
}
}
这是我的第一堂课,也是其他大多数课程的超课堂
共 (0) 个答案