﻿class Singleton
{
    // Attributes
    private static _instance: Singleton = new Singleton();
    private _data: string;

    // Constructor
    constructor()
    {
        if(Singleton._instance){
            throw new Error("Error: Instantiation failed: Use Singleton.getInstance() instead of new.");
        }
        Singleton._instance = this;
    }

    // Properties
    static get Instance(): Singleton
    {
        return Singleton._instance;
    }

    get Data(): string
    {
        return this._data;
    }

    set Data(data: string)
    {
        this._data = data;
    }

    // Methods
    SayHello(): void
    {
        window.alert("Hello");
    }
} 