mirror of
https://code.lenaisten.de/Lenaisten/advent22.git
synced 2024-11-23 00:03:07 +00:00
ts overload constructors
This commit is contained in:
parent
0dd96f5949
commit
dd156b936d
3 changed files with 6 additions and 0 deletions
|
@ -4,6 +4,8 @@ export class Door {
|
|||
private _day = -1;
|
||||
public position: Rectangle;
|
||||
|
||||
constructor(position: Rectangle);
|
||||
constructor(position: Rectangle, day: number);
|
||||
constructor(position: Rectangle, day = -1) {
|
||||
this.day = day;
|
||||
this.position = position;
|
||||
|
|
|
@ -4,6 +4,8 @@ export class Rectangle {
|
|||
private readonly corner_1: Vector2D;
|
||||
private readonly corner_2: Vector2D;
|
||||
|
||||
constructor();
|
||||
constructor(corner_1: Vector2D, corner_2: Vector2D);
|
||||
constructor(corner_1 = new Vector2D(), corner_2 = new Vector2D()) {
|
||||
this.corner_1 = corner_1;
|
||||
this.corner_2 = corner_2;
|
||||
|
|
|
@ -2,6 +2,8 @@ export class Vector2D {
|
|||
public readonly x: number;
|
||||
public readonly y: number;
|
||||
|
||||
constructor();
|
||||
constructor(x: number, y: number);
|
||||
constructor(x = 0, y = 0) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
|
Loading…
Reference in a new issue