Skip to content

Instantly share code, notes, and snippets.

@jawache
Created September 22, 2016 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jawache/5bcd48b74e151c6a6841cb317376b0a1 to your computer and use it in GitHub Desktop.
Save jawache/5bcd48b74e151c6a6841cb317376b0a1 to your computer and use it in GitHub Desktop.
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