package per;
public class Person {
protected String sex;
protected String name;
protected String age;
public Person(String sex,String name,String age) {
this.sex=sex;
this.name=name;
this.age=age;
}
public String toString() {
return "姓名:"+name+" "+"性别:"+sex+"年龄:"+age;
}
public class Teacher extends Person{
protected String position;
protected String section;
public Teacher(String sex,String name,String age,String position,String section)
{ super(sex,name,age);
this.position=position;
this.section=section;
}
public String toString() {
return "姓名:"+name+" "+"性别:"+sex+"年龄:"+age+"职位:"+position+"部门:"+section;
}
}
public class Student extends Person{
protected String stunum;
protected String entertime;
protected String major;
public Student(String sex,String name,String age,String stunum,String entertime, String major) {
super(sex,name,age);
this.stunum=stunum;
this.entertime=entertime;
this.major=major;
}
public String toString() {
return "姓名:"+name+" "+"性别:"+sex+"年龄:"+age+"学号"+stunum+"入学时间"+entertime+"专业"+major;
}
public static void main(String args[])
{
Person a=new Person("男","张三","18");
System.out.println(a.toString());
Teacher b=new Teacher ("女","李四","33","教授","计算机学院");
System.out.println(b.toString());
Student c=new Student ("女","王五","22","123","2021.9.1","计算机");
System.out.println(c.toString());
}
}
}
怎么修改不报错Teacher b=new Teacher ("女","李四","33","教授","计算机学院");