class People{
constructor(name,age,sex){
this.name=name;
this.age=age;
this.sex=sex;
}
sayHello(){
console.log("你们好"+"我的名字是"+this.name+"年龄"+this.age+"性别"+this.sex)
}
}
class Student extends People{
constructor(name,age,sex,shengao){
super(name,age,sex);
this.shengao=shengao;
}
sayHello(){
console.log("你们好"+"我的名字是"+this.name+"年龄"+this.age+"性别"+this.sex+"身高"+this.shengao)
}
girlfriend(){
console.log("她的身高"+this.shengao);
}
}
var people=new People("小红",18,"女");
people.sayHello();
var xiaoming=new Student("小红",18,"女","179");
xiaoming.sayHello();
xiaoming.boyfriend();
16、类
猜你喜欢
转载自blog.csdn.net/sinat_36414515/article/details/81380333
今日推荐
周排行