定义一个Person类,包含姓名、性别、年龄等字段;继承Person类设计Teacher类,增加职称、部门等字段;继承Person类设计Student类,增加学号、入学时间、专业等字段。定义各

时间:2025-04-02 08:11:24
public class person {
    int age;String name;String gender;
    public person(int Age,String Name,String Gender) {
        =Age;
        =Name;
        =Gender;
    }
    public person(String string) {
        // TODO Auto-generated constructor stub
    }
    public String toString() {
        return"name:"+name+" gender:"+gender+" age:"+age;
    }
    public static class Teacher extends person{
         private static final int Age = 0;
        private static final String Gender = null;
        private static final String Title = null;
        private static final String Department = null;
        String title; String department;
        public Teacher(String Name) {
            super(Age,Name,Gender);
            =Title;
            =Department;
        }
    public String toString() {
        return ()+" title:"+title+" department:"+department;
    }        
    }
    public static class Student extends person{
        private static final String Gender = null;
        private static final int Age = 0;
        private static final int Number = 0;
        private static final int Time = 0;
        private static final String Major = null;
        int number;int time;String major;    
        public Student(String Name) {
            super(Age,Name,Gender);
            =Number;
            =Time;
            =Major;
        }
    public String toString() {
        return ()+" number:"+number+" time:"+time+" major"+major;
    }
    }
    public static void main(String a[]) {
        Teacher person1=new Teacher("");
        (person1);
        Student person2=new Student("");
        (person2);
    }
}