コード例 #1
0
        private void BtnCreateFlight_Click_1(object sender, EventArgs e)
        {
            string   type   = cbPlaneType.Text;
            Airplane custom = FlightInformation.GetPlane(type);

            switch (cbPlaneType.SelectedItem)
            {
            case "Dornier 328": FlightInformation.AddInformation(new Airplane(type, 25, 5)); break;

            case "Boeing 737": FlightInformation.AddInformation(new Airplane(type, 180, 20)); break;

            case "Boeing 767": FlightInformation.AddInformation(new Airplane(type, 360, 40)); break;

            case "Boeing 747-8": FlightInformation.AddInformation(new Airplane(type, 400, 60)); break;

            case "Airbus A380": FlightInformation.AddInformation(new Airplane(type, 700, 150)); break;

            default:
                if (cbPlaneType.SelectedItem.ToString() == custom.Type)
                {
                    FlightInformation.AddInformation(new Airplane(custom.Type, custom.AmountOfEconomySeats, custom.AmountOfBusinessSeats));
                }

                break;
            }
        }
コード例 #2
0
        private void BtnAddPassengers_Click(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(tbSearchID.Text);

                Airplane a = FlightInformation.GetAirplaneInfo(id);

                if (a.InUse == false)
                {
                    for (int i = 1; i <= a.AmountOfBusinessSeats; i++)
                    {
                        a.AddBusinessSeat(new Seat($"{i}{lettersTwo()[i]}"));
                    }
                    for (int i = 1; i <= a.AmountOfEconomySeats; i++)
                    {
                        a.AddEconomySeat(new Seat($"{i}{letters()[i]}"));
                    }
                    ap           = new AddPassangers(a, this);
                    this.Visible = false;
                    ap.Show();
                }
                else
                {
                    MessageBox.Show("This airplane is already in use!");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Please make sure the information is correct!");
            }
        }
コード例 #3
0
 private void CbPlaneType_Click(object sender, EventArgs e)
 {
     foreach (Airplane a in FlightInformation.GetCustomPlanes())
     {
         while (!cbPlaneType.Items.Contains(a.Type))
         {
             cbPlaneType.Items.Add(a.Type);
         }
     }
 }
コード例 #4
0
 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!");
     }
 }
コード例 #5
0
 private void BtnFlightInformation_Click_1(object sender, EventArgs e)
 {
     try
     {
         int      id = Convert.ToInt32(tbSearchID.Text);
         Airplane a  = FlightInformation.GetAirplaneInfo(id);
         FlightInformationForm info = new FlightInformationForm(a);
         info.Show();
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please make sure the information is correct!");
     }
 }
コード例 #6
0
 private void TbSearchAirplane_Click_1(object sender, EventArgs e)
 {
     try
     {
         lbCreatedAriplanes.Items.Clear();
         int      id = Convert.ToInt32(tbSearchID.Text);
         Airplane a  = FlightInformation.GetAirplaneInfo(id);
         lbCreatedAriplanes.Items.Add(a.GetInfoInUse());
     }
     catch (Exception ex)
     {
         MessageBox.Show("Please make sure the information is correct!");
     }
 }
コード例 #7
0
        private List <string> lettersTwo()
        {
            int id = Convert.ToInt32(tbSearchID.Text);

            Airplane      a    = FlightInformation.GetAirplaneInfo(id);
            List <string> test = new List <string>();

            for (int i = 0; i <= a.AmountOfBusinessSeats; i++)
            {
                test.Add("A");
                test.Add("B");
            }
            return(test);
        }
コード例 #8
0
        private void BtnDelete_Click(object sender, EventArgs e)
        {
            int      id = Convert.ToInt32(tbSearchID.Text);
            Airplane a  = FlightInformation.GetAirplaneInfo(id);

            if (a.InUse == false)
            {
                FlightInformation.RemoveAirplane(id);
            }
            else
            {
                MessageBox.Show("Tou cannot remove an airplane that is in use!");
            }
        }
コード例 #9
0
 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());
 }
コード例 #10
0
 private void BtnRefresh_Click(object sender, EventArgs e)
 {
     lbCreatedAriplanes.Items.Clear();
     foreach (Airplane a in FlightInformation.GetInformation())
     {
         if (a.InUse == false)
         {
             lbCreatedAriplanes.Items.Add(a.GetInfoCreated());
         }
         else
         {
             lbCreatedAriplanes.Items.Add(a.GetInfoInUse());
         }
     }
 }
コード例 #11
0
        private void BtnCreate_Click(object sender, EventArgs e)
        {
            string type         = tbType.Text;
            double business     = Convert.ToDouble(nmBusiness.Value);
            int    economy      = Convert.ToInt32(nmEconomy.Value);
            int    businessPerc = Convert.ToInt32(business + (business / 100 * 40));

            if (FlightInformation.GetPlane(type) == null)
            {
                if ((economy >= 20) && (economy > businessPerc))
                {
                    FlightInformation.AddCustomPlane(new Airplane(economy, Convert.ToInt32(business), type));
                }
                else
                {
                    MessageBox.Show("Economy seats must be at least 20" + "\n" + "Business seats must be 40% less than economy seats");
                }
            }
            else
            {
                MessageBox.Show("This airplane type already exists!");
            }
        }