예제 #1
0
        public static Autopark CreateAutopark()
        {
            Minibuses minibuses1 = new Minibuses();
            minibuses1.Name = "Mercedes-Benz V250";
            minibuses1.Price = 2452;
            minibuses1.Way = "Москва - Санкт-Петербург";
            minibuses1.Company = "ПАТП";
            minibuses1.Fuelconsumption = 12;
            minibuses1.Gradyear = 1998;

            Taxi taxi1 = new Taxi();
            taxi1.Name = "BMW M5";
            taxi1.Price = 300;
            taxi1.Way = "Вокзал - Киевская 23";
            taxi1.Company = "Лидер";
            taxi1.Color = "Синий";
            taxi1.Speed = 60;

            Autopark autopark = new Autopark();
            autopark.AddTransport(minibuses1);
            autopark.AddTransport(taxi1);

            return autopark;
        }
예제 #2
0
파일: Form2.cs 프로젝트: Demonuga/transport
 private void button1_Click(object sender, EventArgs e)
 {
     if (comboBox1.Text == "Автобусы")
     {
         Buses buses = new Buses();
         buses.Name = textBox1.Text;
         buses.Way = textBox2.Text;
         buses.Price = Convert.ToInt16(textBox3.Text);
         buses.Passengercount = Convert.ToInt16(textBox4.Text);
         buses.Dimensions = textBox5.Text;
         buses.Parkname = textBox6.Text;
         autopark1.AddTransport(buses);
     }
     if (comboBox1.Text == "Маршрутные такси")
     {
         Minibuses minibuses = new Minibuses();
         minibuses.Name = textBox1.Text;
         minibuses.Way = textBox2.Text;
         minibuses.Price = Convert.ToInt16(textBox3.Text);
         minibuses.Fuelconsumption = Convert.ToInt16(textBox7.Text);
         minibuses.Company = textBox8.Text;
         minibuses.Gradyear = Convert.ToInt16(textBox9.Text);
         autopark1.AddTransport(minibuses);
     }
     if (comboBox1.Text == "Такси")
     {
         Taxi taxi = new Taxi();
         taxi.Name = textBox1.Text;
         taxi.Way = textBox2.Text;
         taxi.Price = Convert.ToInt16(textBox3.Text);
         taxi.Fuelconsumption = Convert.ToInt16(textBox7.Text);
         taxi.Company = textBox8.Text;
         taxi.Color = textBox10.Text;
         taxi.Speed = Convert.ToInt16(textBox11.Text);
         autopark1.AddTransport(taxi);
     }
     if (comboBox1.Text == "Трамваи")
     {
         Trams trams = new Trams();
         trams.Name = textBox1.Text;
         trams.Way = textBox2.Text;
         trams.Price = Convert.ToInt16(textBox3.Text);
         trams.Passengercount = Convert.ToInt16(textBox4.Text);
         trams.Dimensions = textBox5.Text;
         trams.Condition = textBox12.Text;
         autopark1.AddTransport(trams);
     }
     form1.listBox1.Items.Clear();
     foreach (AbstractTransport route in transport1)
     {
         form1.listBox1.Items.Add("Название транспорта: " + route.Name + "; Маршрут: " + route.Way + "; Стоимость поездки: " + route.Price);
     }
     form1.UpdateLength();
     Close();
 }