コード例 #1
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!");
            }
        }