import {CHour} from '../classes/CHour';
import {IKey} from '../interfaces/IKey';

export class CFlight implements IKey
{
    public readonly IDFlight: string;
    public readonly FlightDate: string;
    public readonly TakeoffWaypointName: string;
    public readonly Glider: string;
    public readonly BestTaskDistance: string;
    public readonly BestTaskType: string;
    public readonly BestTaskPoints: string;
    public readonly FlightDuration: CHour;
    public readonly FlightDurationDispl: string; // need for sorting 
    public readonly FKSeason: string;
    
    constructor(inData: any) 
    {
        this.IDFlight = inData.IDFlight;
        this.FlightDate = inData.FlightDate;
        this.TakeoffWaypointName = inData.TakeoffWaypointName;
        this.Glider = inData.Glider;
        this.BestTaskDistance = inData.BestTaskDistance;
        this.BestTaskType = inData.BestTaskType;
        this.BestTaskPoints = inData.BestTaskPoints;
        this.FKSeason = inData.FKSeason;
        this.FlightDuration = new CHour(+inData.FlightDuration);
        this.FlightDurationDispl = this.FlightDuration.Print();       
    }

    public get key()
    {
        return this.IDFlight;
    }
}
