尚学堂离得一个程序,自己新手搞不定,希望高手能帮忙解决一下,先谢谢各位了!
运行说:找不到符号 
                        符号:方法info()  
                              。程序:
class Person{
private String name;
private String location;

Person(String name){
this.name = name;
location ="beijing";
}
  Person(String name,String location){
  this.name = name;
  this.location = location;
  }
  public String info(){
  return  "name: "+name+
  " location: "+location;
  }
}class Teacher extends Person{
private String capital;
Teacher(String name, String capital){
this(name,"beijing",capital);
}
Teacher(String n,String l,String capital){
super(n,l);
this.capital = capital;
}
public String info(){
return super.info() + "capital" +capital;
}

}
class Student extends Person{
private String school;
Student(String name,String school){
this(name,"beijing",school);
}
Student(String n,String l,String school){
super(n,l);
this.school = school;
}
public String info(){
return super.info()+"school: "+school;
}
}public class TestTeacher{
public static void main (String [] args){

Person p1 = new Person("A");
Person p2 = new Person("B","shanghai");
Student s1 = new Person("c",s1);
Student s2 = new Person("c","shanghai","s2");

System.out.println(p1,info());
System.out.println(p2,info());
System.out.println(s1,info());
System.out.println(s2,info());

Teacher t1 = new Teacher("d","Professor");
System.out.println(t1,info());
}
}

解决方案 »

  1.   

    这个类改下
    public class TestTeacher {
    public static void main(String[] args) { Person p1 = new Person("A");
    Person p2 = new Person("B", "shanghai");
    Student s1 = new Student("c", "s1");
    Student s2 = new Student("c", "shanghai", "s2"); System.out.println(p1.info());
    System.out.println(p2.info());
    System.out.println(s1.info());
    System.out.println(s2.info()); Teacher t1 = new Teacher("d", "Professor");
    System.out.println(t1.info());
    }
    }
      

  2.   

    Student s1 = new Person("c", s1);
    Student是Person的子类
      

  3.   

    补充下我修改的内容Student s1 = new Person("c",s1);//Person类改成Student,s1加上引号
    Student s2 = new Person("c","shanghai","s2");//Person类改成Studentprintln(p1,info());//是p1.info()不是逗号,是点,下面一样
      

  4.   

    整个文件发给你把,覆盖原来的
    class Person {
    private String name;
    private String location; Person(String name) {
    this.name = name;
    location = "beijing";
    } Person(String name, String location) {
    this.name = name;
    this.location = location;
    } public String info() {
    return "name: " + name + " location: " + location;
    }
    }class Teacher extends Person {
    private String capital; Teacher(String name, String capital) {
    this(name, "beijing", capital);
    } Teacher(String n, String l, String capital) {
    super(n, l);
    this.capital = capital;
    } public String info() {
    return super.info() + "capital" + capital;
    }}class Student extends Person {
    private String school; Student(String name, String school) {
    this(name, "beijing", school);
    } Student(String n, String l, String school) {
    super(n, l);
    this.school = school;
    } public String info() {
    return super.info() + "school: " + school;
    }
    }public class TestTeacher {
    public static void main(String[] args) { Person p1 = new Person("A");
    Person p2 = new Person("B", "shanghai");
    Student s1 = new Student("c", "s1");
    Student s2 = new Student("c", "shanghai", "s2"); System.out.println(p1.info());
    System.out.println(p2.info());
    System.out.println(s1.info());
    System.out.println(s2.info()); Teacher t1 = new Teacher("d", "Professor");
    System.out.println(t1.info());
    }
    }
      

  5.   

    谢谢啊  看来自己的java的路还有很远很远。。