zheng 1 săptămână în urmă
părinte
comite
17ee480432

+ 23 - 0
11.ts/面向对象/dist/4.super.js

@@ -0,0 +1,23 @@
+"use strict";
+(function () {
+    class Animal {
+        constructor(name, sex) {
+            this.name = name;
+            this.sex = sex;
+        }
+        eat() {
+            console.log("吃东西");
+        }
+    }
+    class Cat extends Animal {
+        constructor(name, sex, age) {
+            super(name, sex);
+            this.age = age;
+        }
+    }
+    let c = new Cat('淼淼', '女', 3);
+    console.log(c.name);
+    console.log(c.sex);
+    console.log(c.age);
+    c.eat();
+})();

+ 12 - 0
11.ts/面向对象/dist/5.接口.js

@@ -0,0 +1,12 @@
+"use strict";
+(function () {
+    class Person2 {
+        constructor(name, age, color) {
+            this.name = name;
+            this.age1 = age;
+            this.color = color;
+        }
+    }
+    let p3 = new Person2('图图', 3, '红');
+    console.log(p3);
+})();

+ 1 - 1
11.ts/面向对象/dist/index.html

@@ -6,6 +6,6 @@
     <title>Document</title>
     <title>Document</title>
 </head>
 </head>
 <body>
 <body>
-    <script src="./3.继承.js"></script>
+    <script src="./5.接口.js"></script>
 </body>
 </body>
 </html>
 </html>

+ 25 - 0
11.ts/面向对象/src/4.super.ts

@@ -0,0 +1,25 @@
+(function() {
+    class Animal{
+        name:string;
+        sex: string;
+        constructor(name:string,sex:string) {
+            this.name = name;
+            this.sex = sex;
+        }
+        eat() {
+            console.log("吃东西")
+        }
+    }
+    class Cat extends Animal {
+        age:number;
+        constructor(name:string,sex:string,age:number) {
+            super(name,sex);
+            this.age = age;
+        }
+    }
+    let c = new Cat('淼淼','女',3);
+    console.log(c.name);
+    console.log(c.sex);
+    console.log(c.age);
+    c.eat()
+})()

+ 19 - 0
11.ts/面向对象/src/5.接口.ts

@@ -0,0 +1,19 @@
+(function() {
+    // 接口 定义数据类型的规范
+    interface vase {
+        name: string,
+        age1: number
+    }
+    class Person2 implements vase {
+        name:string;
+        age1: number;
+        color: string;
+        constructor(name:string,age:number,color:string) {
+            this.name = name;
+            this.age1 = age;
+            this.color = color;
+        }
+    }
+    let p3 = new Person2('图图',3,'红');
+    console.log(p3);
+})()