private void btnIncreaseAge_Click(object sender, EventArgs e) { int pilotNumber = Convert.ToInt32(tbPilotNumber.Text); Pilot pilot = airlines.FindPilot(pilotNumber); if (pilot != null) { pilot.Age++; } else { MessageBox.Show("There are no pilots with this number!"); } ShowPilots(); }
/// <summary> /// Creates several "fake" pilots and adds them to the airlines object. /// </summary> private void CreateFakePilots() { Pilot pilot = new Pilot("John Perry", 30); // pilot.OnFullCapacity += this.PilotCapacityFull; pilot.AddFlight(110); pilot.AddFlight(60); airlines.AddPilot(pilot); pilot = new Pilot("Ann Smiths", 40); // pilot.OnFullCapacity += this.PilotCapacityFull; pilot.AddFlight(75); airlines.AddPilot(pilot); pilot = new Pilot("Joe Jefferson", 33); // pilot.OnFullCapacity += this.PilotCapacityFull; pilot.AddFlight(120); airlines.AddPilot(pilot); pilot = new Pilot("Jack Gibbs", 45); // pilot.OnFullCapacity += this.PilotCapacityFull; pilot.AddFlight(90); airlines.AddPilot(pilot); }
/// <summary> /// Removes one pilot for the airlines. /// </summary> /// <param name="pilot"></param> public void RemovePilot(Pilot pilot) { pilots.Remove(pilot); }
/// <summary> /// Add a new pilot to the airlines. /// </summary> /// <param name="pilot">The pilot that should be added.</param> public void AddPilot(Pilot pilot) { pilots.Add(pilot); }
public Node(Pilot pilot) { this.pilot = pilot; this.next = null; }
private void PilotCapacityFull(Pilot pilot, int overHours) { MessageBox.Show("Pilot " + pilot.Name + " has full capacity and will be removed from the list!\nHe/she now has " + pilot.FlightHours + " flight hours, and that is " + overHours + " hours of over work!"); airlines.RemovePilot(pilot); ShowPilots(); }