private void btnAddSportsCar_Click(object sender, EventArgs e)
        {
            // Instantiate a new radio and create a new sports Car
            Radio     aNewRadio  = new Radio("Sony");
            SportsCar myDreamCar = new SportsCar("Ferrari", "GT330", "Red", "Coupe", aNewRadio);

            myDreamCar.CarRadio.SwitchOn();
            myDreamCar.CarRadio.Channel = "RTE 1";
            lstDisplay.Items.Add(myDreamCar);
        }
Example #2
0
 private void btAddCar_Click(object sender, EventArgs e)
 {
     if (isSportsCar)
     {
         Car sportscar = new SportsCar(tbBrand.Text, tbModel.Text, DateTime.Parse(mtbInUseDate.Text), mtbLicensePlate.Text, int.Parse(nudHorsePower.Value.ToString()), int.Parse(nudSpeedSettings.Value.ToString()));
         Cars.Add(sportscar);
     }
     else
     {
         Car familycar = new FamilyCar(tbBrand.Text, tbModel.Text, DateTime.Parse(mtbInUseDate.Text), mtbLicensePlate.Text, int.Parse(nudHorsePower.Value.ToString()), int.Parse(nudSpeedSettings.Value.ToString()));
         Cars.Add(familycar);
     }
     lbCars.Items.Clear();
     foreach (Car car in Cars)
     {
         lbCars.Items.Add(car);
     }
 }