Skip to content

Instantly share code, notes, and snippets.

@nbogie
Created January 23, 2023 15:55
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 nbogie/5a6a9b8e54f975d8cc7eeea92ce416f1 to your computer and use it in GitHub Desktop.
Save nbogie/5a6a9b8e54f975d8cc7eeea92ce416f1 to your computer and use it in GitHub Desktop.
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