class Person
{
public static void main(String[] args)
{ String name="abc",sex="m",age="19";
System.out.println("The name is "+name+",sex is "+sex+",age is "+age);
Student stu=new Student("2017年",28);
Teacher tea=new Teacher("cjc","abc");
System.out.println(stu);
System.out.println(tea);
}
}
class Student extends Person
{
private String time;
private int num;
Student(String str,int number)
{
time=str;
num=number;
}
public String toString()
{
return "The time is "+time+"."+"The num is "+num+".";
}
}
class Teacher extends Person
{
private String title;
private String section;
Teacher(String str,String num)
{
title=str;
section=num;
}
public String toString() { return "The title " +title+".The section is " +section+".";
}
}
这个程序该怎样修改,才能在输出学生的时候输出的是它的名字,性别,年龄,学号和时间;
在输出教师的时候输出的只有名字,性别,年龄,职称和部门。