Skip to content

Commit

Permalink
object-oriented-terms: typo
Browse files Browse the repository at this point in the history
  • Loading branch information
evan361425 authored Feb 2, 2024
1 parent 66f8043 commit c6b4733
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/essay/code/object-oriented-terms.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const dog = new Dog();

### 介面

除了抽象類別,你也可以用介面來把抽象層度拉高
除了抽象類別,你也可以用介面(interface)來把抽象程度拉高

```typescript
interface Animal {
Expand Down Expand Up @@ -181,13 +181,13 @@ abstract class Dog implements Animal {
- *私有*(private)、*保護*(protected)、*公開*(public) 的差別
- *介面*(interface) 和 *抽象類別*(abstract class) 的差別

| 種類 | 建構 | 實作 | 抽象層度 |
| 種類 | 建構 | 實作 | 抽象程度 |
| -------------- | ---- | ---- | -------- |
| class | O | O ||
| abstract class | X | O ||
| interface | X | X ||

**為什麼要拉高抽象層度**
**為什麼要拉高抽象程度**

想像一下朋友打電話給你,問你在幹嘛,你可以有兩種選擇:

Expand All @@ -213,6 +213,7 @@ function isGoodEnv(animals: Animal[]): boolean {
雖然介面和抽象類別不能建構,但是他可以被用作型別(type)。

```typescript
// 挑逗動物,會觸法它吼叫
function influriate(animal: Animal) {
return animal.shout();
}
Expand Down

0 comments on commit c6b4733

Please sign in to comment.