Created
August 13, 2020 23:03
-
-
Save lebowvsky/837fed96dcf3936c35ba48cc1c877b4b to your computer and use it in GitHub Desktop.
POO en typescript 1
This file contains hidden or 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
class Person { | |
private name: string; | |
private age: number; | |
constructor(name: string, age: number) { | |
this.name = name; | |
this.age = age; | |
} | |
tellMyName(): string { | |
return `I am ${this.name}` | |
} | |
tellMyAge(): string { | |
return `I am ${this.age} years old` | |
} | |
} | |
const person1 = new Person('John', 40); | |
console.log(person1.tellMyName()); | |
console.log(person1.tellMyAge()); | |
const person2 = new Person('Mary', 35); | |
console.log(person2.tellMyName()); | |
console.log(person2.tellMyAge()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment