在业余时间处理项目时,我遇到了2个错误
var onChosenFileToOpen = function(theFileEntry) {
$('.nav-tabs li:nth-child(' + $(".nav-tabs").children().length + ') a').click(); //synchronous function that creates a tab
var checker=setInterval(()=>{
if(currentiframe.contentWindow && currentiframe.contentWindow.editor){//waits those 2 conditions to be true
currentiframe.contentWindow.readFileIntoEditor(theFileEntry)//content is loaded to that tab
clearInterval(checker)
}
},1)};
但是,Human类是在与我的测试器类相同的目录中的另一个文件中创建的。
人类阶级:
Error:(3, 9) cannot find symbol
symbol: class Human
location: class tester
Error:(3, 25) cannot find symbol
symbol: class Human
location: class tester
测试器类:
public class Human extends Character{
private boolean excercising;
private boolean studying;
public Human(){this(0,0.0,0,0,"<NoName>");} //default Constructor
//calls non-default
//constructor <below>
public Human(int i, double j, int k, int l, String m ){ //non-
//default constructor, didn't
//feel like making over 2
intellect = i; //constructors
height = j;
age = k;
strength = l;
name = m;
}
public void Exercising(int time){ //In retrospect, this and
//Studying could have been
//done in the set methods but
excercising = true; // whatever, it's a good way
to demonstrate class calls.
for(int t = 0; t < time; t++){
setStrength(); // Class call with no
//parameters
}
excercising = false;
}
public void setStrength(){
if(excercising){
strength = strength + 1; //long increment (can change
//increment factor to 2, 3, etc.)
}
}
public void Studying(int time){
studying = true;
for(int t = 0; t < time; t++){ //standard for-loop
setIntellect();
}
studying = false;
}
public void setIntellect(){
if(studying){
intellect++; //super-simple increment only by 1
}
}
public void birthday(){
age+=1; //simple increment (can change increment factor to 2, 3, etc.)
System.out.println("Happy Birthday to " + name + " who is now
"+ age +" years old.");
}
public String toString(){
return "Human " + super.toString();
}
}
我希望它返回一个字符串,相反,我发现类未找到错误。
在重要的情况下,我正在使用IntelliJ IDEA社区版2019.1。
答案 0 :(得分:-2)
我认为您不能在对象上执行“ .toString()”,您应该这样做并使用bob.getName()而不是bob.toString():
公共类人类扩展角色{
String name;
public void setName(String name){
this.name = name;
}
public String getName(){
return name;
}
public Human(String name){
this.setName(name)
}
}