예제 #1
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            StatusText = "";//clear status display

            Car PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);

            if (txtMake.Text == "" && txtPrice.Text == "" && txtYear.Text == "" && txtColor.Text == "")
            {
                SubmitWithNoDataDefault();//if nothing is entered, return default data

                PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);
                txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                StatusText   = "Default Car: ";
                StatusText  += PolyMorphCar.GetCarInfo().ToString();
            }
            else
            {
                SubmitWithUserData(); //get user input, assign to variables
                string horsePower = txtBox_Horsepower.Text;

                //Car Poly;
                if (rdbYes.Checked == true)
                {
                    PolyMorphCar = new SportsCar(vehicleMake, vehicleYear, vehicleColor, vehiclePrice, horsePower);
                    txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                    StatusText   = "Sports Car: " + PolyMorphCar.GetCarInfo().ToString();
                    //StatusText += " " + PolyMorphCar.GetCarInfo();
                }
                else //rdbNo is selected
                {
                    PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);
                    txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                    StatusText   = "Regular Car: " + PolyMorphCar.GetCarInfo().ToString();
                    //StatusText += " " + PolyMorphCar.GetCarInfo();
                }
            }
        }//END btn_Submit
예제 #2
0
        private void btn_Submit_Click(object sender, EventArgs e)
        {
            StatusText = "";//clear status display

            Car PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);

            if(txtMake.Text == "" && txtPrice.Text == "" && txtYear.Text == "" && txtColor.Text == ""){
                SubmitWithNoDataDefault();//if nothing is entered, return default data

                PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);
                txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                StatusText = "Default Car: ";
                StatusText += PolyMorphCar.GetCarInfo().ToString();
            }
            else
            {
                SubmitWithUserData(); //get user input, assign to variables
                string horsePower = txtBox_Horsepower.Text;

                //Car Poly;
                if (rdbYes.Checked == true)
                {
                    PolyMorphCar = new SportsCar(vehicleMake, vehicleYear, vehicleColor, vehiclePrice, horsePower);
                    txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                    StatusText = "Sports Car: " + PolyMorphCar.GetCarInfo().ToString();
                    //StatusText += " " + PolyMorphCar.GetCarInfo();
                }
                else //rdbNo is selected
                {
                    PolyMorphCar = new Car(vehicleMake, vehicleYear, vehicleColor, vehiclePrice);
                    txtInfo.Text = PolyMorphCar.GetCarInfo().ToString();
                    StatusText = "Regular Car: " + PolyMorphCar.GetCarInfo().ToString();
                    //StatusText += " " + PolyMorphCar.GetCarInfo();
                }
            }
        }