Пример #1
0
        private void ShowTable()
        {
            Txt_average_weight.Text = company.GetAverageCurbWeight().ToString();
            lw_table.Items.Clear();
            int i;

            for (i = 0; i < Math.Min(5, company.GetCountOfFlights()); i++)
            {
                lw_table.Items.Add(company.GetFlight(i));
            }
            if (company.GetCountOfFlights() > 8)
            {
                lw_table.Items.Add(new AirCompany.flight {
                    number = "..."
                });
            }
            if (company.GetCountOfFlights() > 5)
            {
                for (int k = Math.Max(company.GetCountOfFlights() - 3, i); k < company.GetCountOfFlights(); k++)
                {
                    lw_table.Items.Add(company.GetFlight(i));
                }
            }
        }
Пример #2
0
        public static void WriteFile(AirCompany company)
        {
            StreamWriter Out;

            try
            {
                Out = new StreamWriter(Constants.path);
                Out.Write("");
                for (int i = 0; i < company.GetCountOfFlights(); i++)
                {
                    flight f = company.GetFlight(i);
                    Out.WriteLine(JsonConvert.SerializeObject(f));
                }
                Out.Close();
            }
            catch
            {
                return;
            }
        }