<script>
class people {
constructor(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
introduce() {}
}
class Student extends people {
constructor(name, age, sex, hobby) {
super(name, age, sex);
this.hobby = hobby;
}
introduce() {}
}
class Teacher extends people {
constructor(name, age, sex, rank, salary) {
super(name, age, sex);
this.rank = rank;
this.salary = salary;
}
introduce() {
console.log(
`我是${this.name}老师, 性别${this.sex}, ${this.age}岁, 现担任${this.rank}一职, 工资到手${this.salary}, 我很幸福`
);
}
}
class pupil extends Student {
constructor(name, age, sex, hobby, birthday) {
super(name, age, sex, hobby);
this.birthday = birthday;
}
introduce() {}
}
class Undergraduate extends Student {
constructor(name, age, sex, hobby, major, school, loverName) {
super(name, age, sex, hobby);
this.major = major;
this.school = school;
this.loverName = loverName;
}
introduce() {}
}
const zhangsanqiang = new Teacher("张三强", 53, "男", "系主任", 1800);
zhangsanqiang.introduce();
</script>