91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

typescript 類 -- 學習筆記三

發布時間:2020-06-17 09:38:29 來源:網絡 閱讀:266 作者:295631788 欄目:web開發

typescript 類 -- 學習筆記三

class Point {
    public x: number
    public y: number
    constructor(x: number, y: number) {
        this.x = x
        this.y = y
    }
    public getPosition() {
        return `${this.x} ${this.y}`
    }
}

const point = new Point(1, 2)

class Parent {
    public name: string
    constructor(name: string) {
        this.name = name
    }
}

class Child extends Parent {
    constructor(name: string) {
        super(name)
    }
}

// public 公共

// private 私有的

// protected 受保護

class Parent1 {
    // private age: number
    protected age: number
    protected constructor(age: number) {
        this.age = age
    }
    protected getAge() {
        return this.age
    }
}

class Child1 extends Parent1 {
    constructor(age: number) {
        super(age)
    }
}

// readonly
class UserInfo {
    public readonly name: string
    constructor(name: string) {
        this.name = name
    }
}

class A {
    constructor(public name: string) {}
}

class Parent3 {
    public static getAge() {
        return Parent3.age
    }
    private static age: number = 18
    constructor() {}
}

class Info {
    public name: string
    public age?: number
    private _infoStr: string
    constructor(name: string, age?: number, public sex?: string) {
        this.name = name
        this.age = age
    }
    get infoStr() {
        return this._infoStr
    }
    set infoStr(value) {
        // console.log(`setter: ${value}`)
        this._infoStr = value
    }
}

// 抽象類,abstract 類不能創建的實例對象。
abstract class People {
    constructor(public name: string) {}
    public abstract printName(): void
}

class Man extends People {
    constructor(name: string) {
        super(name)
        this.name = name
    }
    public printName() {
        console.log(this.name)
    }
}
const m = new Man('lison')
m.printName()

abstract class People1 {
    public abstract _name: string
    abstract get insideName(): string
    abstract set insideName(value: string)
}
class P extends People1 {
    public _name: string
    public insideName: string
}

class People3 {
    constructor(public name: string) {}
}
let p2: People3 = new People3('lison')
class Animal {
    constructor(public name: string) {}
}
p2 = new Animal('haha')

// 接口
interface FoodInterface {
    type: string
}
class FoodClass implements FoodInterface {
    public type: string
}

class A1 {
    protected name: string
}
interface I extends A1 {}

class B extends A1 implements I {
    public name: string
}

const create = <T>(c: new() => T): T => {
    return new c()
}
class Infos {
    public age: number
    constructor() {
        this.age = 18
    }
}
向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

赤城县| 凭祥市| 宜宾县| 松潘县| 康马县| 黄骅市| 丰顺县| 慈溪市| 峡江县| 格尔木市| 敦化市| 林甸县| 玉树县| 慈溪市| 永胜县| 鹤庆县| 商洛市| 高清| 稷山县| 盱眙县| 灵璧县| 平和县| 聊城市| 东阳市| 正蓝旗| 侯马市| 中西区| 临沧市| 宁乡县| 海伦市| 广河县| 八宿县| 营口市| 会理县| 扬中市| 新巴尔虎右旗| 伊宁市| 和平县| 安泽县| 扶沟县| 健康|