Created
September 23, 2024 17:10
-
-
Save teasmade/39d3cd35cdfb4deca43b9b521b7c1724 to your computer and use it in GitHub Desktop.
WCS TS-POO Q1
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 { | |
name: string; | |
age: number; | |
constructor(name: string, age: number) { | |
this.name = name; | |
this.age = age; | |
} | |
tellMyName() { | |
console.log(`I am ${this.name}`); | |
} | |
tellMyAge() { | |
console.log(`I am ${this.age} years old`); | |
} | |
} | |
const john = new Person('John', 40); | |
john.tellMyName(); | |
john.tellMyAge(); | |
const mary = new Person('Mary', 35); | |
mary.tellMyName(); | |
mary.tellMyAge(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment