java 编程中出现的 找不到符号 的问题

来源:百度知道 编辑:UC知道 时间:2024/06/26 00:27:21
class Person
{
protected String name,sex,city;
protected int age;
public Person(String n,String s,String c,int a)//超类的构造方法
{
this.name=n; this.sex=s; this.city=c; this.age=a;
}
public void ShowInfo()
{
System.out.print("姓名\t"+name+"\t");
System.out.print("年龄\t"+age+"\t");
System.out.print("性别\t"+sex+"\t");
System.out.print("城市\t"+city+"\t");
}
}

class Student extends Person
{
int num; String dept;//添加子类成员
Student(String n,String s,String c,String d,int nu,int a)
{ super(n,s,c,a);
num=nu; dept=d;
}
public void ShowInfo()
{
super.ShowInfo();
System.out.print("学号"+num);
System.out.print("系别"+dept);
}
}

class Teacher extends Person
{
int money;

给你改了一下:可以运行了

class Person
{
protected String name,sex,city;
protected int age;
public Person(String n,String s,String c,int a)//超类的构造方法
{
this.name=n; this.sex=s; this.city=c; this.age=a;
}
public void ShowInfo()
{
System.out.print("姓名\t"+name+"\t");
System.out.print("年龄\t"+age+"\t");
System.out.print("性别\t"+sex+"\t");
System.out.print("城市\t"+city+"\t");
}
}

class Student extends Person
{
int num; String dept;//添加子类成员
Student(String n,String s,String c,String d,int nu,int a)
{ super(n,s,c,a);
num=nu; dept=d;
}
public void ShowInfo()
{
super.ShowInfo();
System.out.print("学号:"+num+"\t");
System.out.print("系别:"+dept);
}
}

class Teacher extends