Created
January 23, 2023 15:55
-
-
Save nbogie/5a6a9b8e54f975d8cc7eeea92ce416f1 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
class Point { | |
x: number; | |
y: number; | |
/** the label for this point */ | |
label: string; | |
constructor(givenLabel: string,givenX: number, givenY:number){ | |
console.log("constructor was called") | |
this.x = givenX; | |
this.y = givenY; | |
this.label = givenLabel; | |
} | |
/** Prints to console a description of this point. */ | |
display():void{ | |
console.log(`${this.label} at ${this.x} ${this.y}`) | |
} | |
} | |
const london = new Point("North London", 2, -3); | |
const dublin = new Point("Dublin City Centre", 100, 200); | |
london.label | |
london.display(); | |
dublin.display(); | |
console.log(london.x) | |
console.log(dublin.x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment