Beispiel #1
0
 //plane can start arrival/landing only if sations 0,1,2,3,7,4 are empty(4-can start parking)
 public static bool IsClearForLanding(AirportDTO airport)
 {
     // same rules as IsClearForDeparture with the exception of station 4
     if (AirportFieldValidator.IsClearForDeparturing(airport)) // if all is true, then can check station 4
     {
         PlaneDTO plane = airport.Planes.FirstOrDefault(p => StationsInfoService.IsAttendingToPark(p.StationId));
         if (plane == null) //no
         {
             return(true);
         }
     }
     return(false);
 }
Beispiel #2
0
 private void ManagePlanesOnHold(AirportDTO airport)
 {
     //mangaing the planes that want to departure/arrival:
     //check if the airport field is clean for departure:
     if (AirportFieldValidator.IsClearForDeparturing(airport))
     {
         // if there is plane that want to departure:
         if (DeparturePlanesOnHold.Count != 0)
         {
             //tell the plane to departure:
             PlaneDTO plane            = DeparturePlanesOnHold.Peek();
             PlaneDTO departuringPlane = airport.Planes.Find(p => p.PlaneId == plane.PlaneId);
             departuringPlane.StationId = StationsInfoService.AttendToDepart;
             //raise event that plane is departuring:
             PlaneDeparturing.Invoke(departuringPlane, EventArgs.Empty);
         }
         else //if there isnt planes that want to depart, check if there is plane that want land
         {
             // if there is plane that want to land:
             if (ArrivalPlanesOnHold.Count != 0)
             {
                 //check if the field clear for landing:
                 if (AirportFieldValidator.IsClearForLanding(airport))
                 {
                     //if field clear tell the plane to land:
                     PlaneDTO plane = ArrivalPlanesOnHold.Dequeue();
                     plane.StationId = StationsInfoService.AttendingToLand.First();
                     //adding plane to airport :
                     airport.Planes.Add(plane);
                     //raise event that plane is arriving:
                     PlaneArriving.Invoke(plane, EventArgs.Empty);
                 }
             }
         }
     }
 }