class Person {
constructor(name) {
this.name = name;
}
drink() {
console.log('喝水')
}
}
class Teacher extends Person {
constructor(name, subject){
super(name);
this.subject = subject;
}
teach() {
console.log(`我是${this.name}, 是${this.subject}老师`)
}
}
const teacher = new Teacher('小孟', '英语')
teacher.teach();
teacher.drink();
class Student extends Person {
constructor(name, score){
super(name);
this.socre = socre;
}
introduce() {
console.log(`我是${this.name}, 考了${this.score}分`)
}
}
const student = new Student('小马', '0')
student.introduce();
student.drink();