Esempio n. 1
0
        public bool UpdateElectricVehicleByModel(string model, Electric newValues)
        {
            UpdateVehicleByModel(model, newValues);
            Electric toUpdate = (Electric)GetVehicleByModel(model);

            if (model == null)
            {
                return(false);
            }
            else
            {
                toUpdate.ChanceBatteryExplodesInCrash = newValues.ChanceBatteryExplodesInCrash;
                return(true);
            }
        }
        public void AddVehicle()
        {
            string vehicleClass = GetVehicleClass();

            Console.WriteLine("Enter the following:\n" +
                              "Vehicle Make:");
            string make = Console.ReadLine();

            Console.WriteLine("Vehicle Model:");
            string model = Console.ReadLine();

            Console.WriteLine("Year Released:");
            int year = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Safety Rating:");
            double safetyRating = Convert.ToDouble(Console.ReadLine());

            Console.WriteLine("Cost to Buy New:");
            double costNew = Convert.ToDouble(Console.ReadLine());

            if (vehicleClass == "Electric")
            {
                Chance   chanceBatteryExplodesInCrash = GetElectricChance();
                Electric newElectric = new Electric(make, model, year, safetyRating, costNew, chanceBatteryExplodesInCrash);
                _electricRepo.AddVehicle(newElectric);
            }
            else if (vehicleClass == "Gas")
            {
                bool isUsedForTowing = GetGasTowing();
                Gas  newGas          = new Gas(make, model, year, safetyRating, costNew, isUsedForTowing);
                _gasRepo.AddVehicle(newGas);
            }
            else
            {
                Hybrid newHybrid = new Hybrid(make, model, year, safetyRating, costNew);
                _hybridRepo.AddVehicle(newHybrid);
            }
            Console.WriteLine("Vehicle added.");
            ReturnToMainMenu();
        }