﻿interface IClock
{
    SetCurrentTime(time: Date): void;
    GetCurrentTime(): Date;

    // Can't specify property getter and setter accessor in typescript interfaces
} 

class ClockA implements IClock
{
    // Attributes
    private _currentTime: Date;

    // Constructor
    constructor()
    {
        this._currentTime = new Date();
    }

    // Properties
    // Get and Set Accessors

    // Methods
    GetCurrentTime(): Date
    {
        return this._currentTime;
    }

    SetCurrentTime(time: Date): void
    {
       this._currentTime = time;
    }
}

class ClockB implements IClock
{
    // Attributes
    private _currentTime: Date;

    // Constructor
    constructor(hours: number, minutes: number)
    {
        this._currentTime = new Date();
        this._currentTime.setHours(hours, minutes);
    }

    // Properties
    // Get and Set Accessors

    // Methods
    GetCurrentTime(): Date
    {
        return this._currentTime;
    }

    SetCurrentTime(time: Date): void
    {
        this._currentTime = time;
    }
}

class TimePrinter
{
    Print(clock: IClock): void
    {
        var hours: number;
        var minutes: number;
        hours = clock.GetCurrentTime().getHours();
        minutes = clock.GetCurrentTime().getMinutes();
        window.alert("Time is " + hours + ":" + minutes);
    }
}


// More advanced probably not necessary
interface IOne
{
    One(): void;
}

interface ITwo
{
    Two(): void;
}

interface IThree extends ITwo
{
    Three(): void;
}

class AAA
{
    Two(): void
    {
        window.alert("Two");
    }
}

class BBB extends AAA implements IOne, IThree
{
    One(): void
    {
        window.alert("One");
    }

    Three(): void
    {
        window.alert("Three");
    }
}

//var bbb: BBB = new BBB();
//bbb.One();
//bbb.Two();
//bbb.Three();