我会正确的。我有一个顾问班,我的司机叫来自建议班。
我的Advisee类与错误问题有关:
public String clearedToGraduateMessage(Advisee advisee1, Advisee advisee2,
Advisee advisee3, Advisee advisee4, Advisee advisee5)
{
if (graduationRequirements)
{
graduationMessage = ("\nYes - all requirements have been met");
}
if (!graduationRequirements)
{
graduationMessage = ("No - ");
if (getHoursCompleted() < 120)
{
graduationMessage += (" not enough hours;");
}
else if (majorSheet == false)
{
graduationMessage += (" not completed major sheet;");
}
else if (intentToGraduate == false)
{
graduationMessage += (" not filed intent to graduate");
}
}
if (advisee1.metGraduationRequirements(advisee1, advisee2, advisee3, advisee4, advisee5)
== true)
advisee1.graduationMessage = ("\nYes - all requirements have been met");
else
{
advisee1.graduationMessage = ("No - ");
if (advisee1.hours < 120)
advisee1.graduationMessage += (" not enough hours;");
else if (majorSheet == false)
advisee1.graduationMessage += (" not completed major sheet;");
else if (intentToGraduate == false)
advisee1.graduationMessage += (" not filed intent to graduate");
}
“if(advisee1.metGraduationRequirements(advisee1,advisee2,advisee3,advisee4 advisee5)== true)”再次重复4次作为相应的引用,为了不发布大量代码,我不会发布那。
驱动程序如下所示:
case 4: //display all advisees that have been cleared to graduate
strClearedToGraduateMessage = clearedToGraduateMessage(advisee1,
advisee2, advisee3, advisee4, advisee5);
它在switch语句中,因为我正在使用菜单。
我尝试编译时出现的“唯一”错误是:
Proj4.java:142: error: cannot find symbol
strClearedToGraduateMessage = clearedToGraduateMessage(advisee1,
^
symbol: method clearedToGraduateMessage(Advisee,Advisee,Advisee,Advisee,Advisee)
location: class Proj4
1 error
如果有人能帮助我搞清楚这个错误,我们将不胜感激。感谢。
答案 0 :(得分:0)
您尚未显示所有相关代码,但似乎在Proj4(驱动程序类)中,您尚未创建要引用的Advisee对象的实例。你需要这样的东西:
Advisee myAdvisee = new Advisee();
String result = myAdvisee.clearedToGraduateMessage(...);
除非您的Advisee方法是静态的,否则您需要创建要引用的对象(即使是静态的,您仍需要引用类名)。
我建议花些时间阅读The Java Tutorials/Classes