import { Rectangle } from "../rects/rectangles"; export class Door { private _day = -1; public position: Rectangle; constructor(position: Rectangle, day = -1) { this.day = day; this.position = position; } public get day(): number { return this._day } public set day(day: unknown) { // integer coercion const result = Number(day); if (isNaN(result)) { this._day = -1; } else { this._day = Math.max(Math.floor(result), -1); } } }