private void BtnAddPassanger_Click(object sender, EventArgs e) { try { int amount = Convert.ToInt32(tbAmount.Text); int businessAmount = Convert.ToInt32(tbBusinessAmount.Text); if ((FlightInformation.GetAllPilots(a).Count == 2 || FlightInformation.GetAllPilots(a).Count == 4) && FlightInformation.GetAllAttendants(a).Count == 6) { if (a.InUse == false) { if (amount <= a.AmountOfEconomySeats && businessAmount <= a.AmountOfBusinessSeats) { a.GetAllEconomySeats().Clear(); a.GetAllBusinessSeats().Clear(); generate.GenerateNames(); for (int i = 1; i <= amount; i++) { int randomFirstName = randomness.Next(50); int randomLastName = randomness.Next(50); int randomAge = randomness.Next(1, 90); a.AddPerson(new Passenger(generate.FirstName()[randomFirstName], generate.LastName()[randomLastName], randomAge)); } for (int i = 1; i <= businessAmount; i++) { int randomFirstName = randomness.Next(50); int randomLastName = randomness.Next(50); int randomAge = randomness.Next(1, 90); a.AddPersonBusiness(new Passenger(generate.FirstName()[randomFirstName], generate.LastName()[randomLastName], randomAge)); } a.AssignSeatsEconomy(); a.AssignSeatsBusiness(); a.CommenceFlight(); } else { MessageBox.Show("Maximum seats for business class: " + a.AmountOfBusinessSeats + "\n" + "Maximum seats for economy class:" + a.AmountOfEconomySeats); } } else { MessageBox.Show("This airplane is already in use!"); } } else { MessageBox.Show("Pilots must be between 2 or 4!" + "\n" + "Attendants must be 6!"); } } catch (Exception ex) { MessageBox.Show("Please make sure the information provided is correct!"); } }
public FlightInformationForm(Airplane a) { InitializeComponent(); this.a = a; lblFlight.Text = a.Name; lblSeat.Text = a.AmountOfTotalSeats.ToString(); lblBusinessSeat.Text = a.AmountOfBusinessSeats.ToString(); lblEconomySeats.Text = a.AmountOfEconomySeats.ToString(); lblPilots.Text = FlightInformation.GetAllPilots(a).Count.ToString(); lblAttendants.Text = FlightInformation.GetAllAttendants(a).Count.ToString(); lblPassengerSeats.Text = Convert.ToString(a.GetAllPeople().Count); lblBusinessPassangers.Text = Convert.ToString(a.GetAllBusinessPeople().Count.ToString()); lblEconomyPassangers.Text = Convert.ToString(a.GetAllEconomyPeople().Count.ToString()); }