<script>
function People(name, age, sex) {
this.name = name;
this.age = age;
this.sex = sex;
}
People.prototype.introduce = function () {};
function Student(name, age, sex, hobby) {
this.name = name;
this.age = age;
this.sex = sex;
this.hobby = hobby;
}
Student.prototype = new People();
Student.prototype.introduce = function () {};
function Teacher(name, age, sex, rank, salary) {
this.name = name;
this.age = age;
this.sex = sex;
this.rank = rank;
this.salary = salary;
}
Teacher.prototype = new People();
Teacher.prototype.introduce = function () {
console.log(
"我是" +
this.name +
"老师, 性别" +
this.sex +
", " +
this.age +
"岁, 现担任" +
this.rank +
"一职, 工资到手" +
this.salary +
", 我很幸福"
);
};
var Pupil = function Pupil(name, age, sex, hobby, birthday) {
this.name = name;
this.age = age;
this.sex = sex;
this.hobby = hobby;
this.birthday = birthday;
};
Pupil.prototype = new Student();
Pupil.prototype.introduce = function () {
console.log(
"您好,我叫" +
this.name +
this.age +
"岁了" +
this.sex +
"生" +
this.hobby +
"是我的爱好" +
this.birthday +
"是我的生日"
);
};
function Undergraduate(name, age, sex, hobby, major, school, loverName) {
this.name = name;
this.age = age;
this.sex = sex;
this.hobby = hobby;
this.major = major;
this.school = school;
this.loverName = loverName;
}
Undergraduate.prototype = new Student();
Undergraduate.prototype.introduce = function () {};
var xiaoming = new Pupil("小明", "男", 5, "看《奥特曼》", " 2016年4月1日");
xiaoming.introduce();
var zhangsanqiang = new Teacher("张三强", 53, "男", "系主任", 1800);
zhangsanqiang.introduce();
</script>