import { User } from './user.class'; import { Plane } from './plane.class'; export class Flight { id:number; flightday_id:number; starttime:string; endtime:string; type:string; comment:string; plane:Plane users:Array; constructor(id:number, flightday_id:number, starttime:string, endtime:string, type:string, comment:string, plane:Plane, users:Array) { this.id = id; this.flightday_id = flightday_id; this.plane = plane; this.starttime = starttime; this.endtime = endtime; this.type = type; this.comment = comment; this.users = users; } public equals(other:Flight) : boolean { if(other) { var keySet1 = Object.keys(this); var keySet2 = Object.keys(other); var j = 0; var isTheSame = true; for(j; j < keySet1.length; j++) { if (this[keySet1[j]] !== other[keySet2[j]]) { // Shit is not the same isTheSame = false; } } return isTheSame; } return false; } public static toFlight(r:any): Flight { let users:Array = new Array(); let plane:Plane = Plane.toPlane(r.PLANE); for(let i = 0; i < r.USERS.length; i++) { users.push(User.toUser(r.USERS[i])); } let flight = new Flight(r.ID, r.FLIGHTDAY_ID, r.DATETIME_START, r.DATETIME_END, r.TYPE, r.COMMENT, plane, users); return flight; } }