示例#1
0
        /// <summary>
        /// Delay the plane by X hours
        /// </summary>
        /// <param name="hours"></param>
        public void Delay(int hours)
        {
            IsLate = true;

            // Set dates for event
            DateTime old = Arrival;

            Arrival = Arrival.AddHours(hours);

            // Create event args
            LateArrivalEventArgs e = new LateArrivalEventArgs
            {
                Flight  = this,
                Planned = old,
                Actual  = Arrival
            };

            // Invoke/trigger event
            this.OnLateArrival?.Invoke(this, e);
        }
示例#2
0
 /// <summary>
 /// On late flight
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void FlightOnLateArrival(object sender, LateArrivalEventArgs e)
 {
     // Invoke own event
     this.OnFlightsUpdated?.Invoke(this, e);
 }
示例#3
0
 /// <summary>
 /// update flights method used to subscribe to flight events
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 public void UpdateFlights(object sender, LateArrivalEventArgs e)
 {
     // Write to console (Output window)
     Console.WriteLine("Plane {0} is delayed by {1} hours!", e.Flight.Name, (e.Actual - e.Planned).TotalHours);
 }
示例#4
0
 protected void AtLateArrival(object sender, LateArrivalEventArgs e)
 {
     // Perhaps notify passengers
 }