Created
September 22, 2016 14:15
-
-
Save jawache/5bcd48b74e151c6a6841cb317376b0a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface Human { | |
firstName: string; | |
lastName: string; | |
name?: Function; | |
isLate?(time: Date): Function; | |
} | |
class Person implements Human { | |
constructor(public firstName, public lastName) { | |
} | |
public name() { | |
return `${this.firstName} ${this.lastName}`; | |
} | |
protected whoAreYou() { | |
return `Hi i'm ${this.name()}`; | |
} | |
} | |
class Student extends Person { | |
course; | |
constructor(firstName, lastName, course) { | |
super(firstName, lastName); | |
this.course = course; | |
} | |
whoAreYou() { | |
return `${super.whoAreYou()} and i'm studying ${this.course}`; | |
} | |
} | |
let asim = new Student("Asim", "Hussain", "typescript"); | |
console.log(asim.whoAreYou()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment