<!DOCTYPE html>
<html lang="zh-Cn">
<head>
<meta charset="UTF-8">
<title>Title</title>
<style>
body {
font-family: "Microsoft YaHei", serif;
}
body, dl, dd, p, h1, h2, h3, h4, h5, h6 {
margin: 0;
}
ol, ul, li {
margin: 0;
padding: 0;
list-style: none;
}
img {
border: none
}
</style>
</head>
<body>
<script>
// 父类
class Person{
constructor(n,a) {
this.name = n;
this.age = a;
}
sayInfo(){
console.log(`姓名:${this.name},年龄:${this.age}。`);
}
}
// 子类
class Teacher extends Person{
constructor(n,a,i) {
super(n,a);
this.id = i;
}
showID(){
console.log(this.id);
}
}
let s = new Teacher("Sherry",15,999);
console.log(s);
console.log(s.sayInfo());
console.log(s.showID());
</script>
</body>
</html>
Python3Turtle