我一直在学习继承并且正在处理一个项目,该项目涉及父母类运动员和儿童类HockeyPlayer。当我编译时,它说我在客户端调用setGoals时找不到符号:
Athlete hockey = new HockeyPlayer();
hockey.setGoals(10);
以下是HockeyPlayer类的代码:
public class HockeyPlayer extends Athlete
{
private int goals, number;
private String team;
public HockeyPlayer()
{
super(); //sets name, age, and salary from Athlete constructor
goals = 0;
number = 0;
team = "";
}
public void setGoals(int goals)
{
this.goals = goals;
}
}
有关如何修复此错误的任何输入?
答案 0 :(得分:0)