TypeScript笔记八

/**
 * Created by ufo9631 on 2017/5/25.
 */
//一
interface IPerson{
    name:string;
    age:number;
}

class  Person {
    constructor(public config:IPerson)
    {

    }
}
var p1=new Person({
    name:"张三",
    age:18
});

//二 实现接口必须实现接口里面的所有方法
interface  Animal{
    eat();
}
class  Sheep implements Animal{
    eat()
    {
        console.log("i eat grass");
    }
}
class  Tiger implements Animal{
    eat()
    {
        console.log("i eat meat");
    }
}

  

posted @ 2017-11-15 22:53  编程猴子  阅读(109)  评论(0编辑  收藏  举报