private void CreateNewCar()
        {
            Console.Clear();

            CarComparison newCar = new CarComparison();

            Console.WriteLine("Enter the type of car:\n" +
                              "1. Electric\n" +
                              "2. Gas\n" +
                              "3. Hybrid");
            string typesAsString = Console.ReadLine();
            int    typesAsInt    = int.Parse(typesAsString);

            newCar.Types = (CarType)typesAsInt;
            Console.WriteLine(newCar.Types);

            Console.WriteLine("Enter the make:");
            newCar.SetMake(Console.ReadLine());

            Console.WriteLine("Enter the model:");
            newCar.SetModel(Console.ReadLine());

            Console.WriteLine("Enter the safety rating:");
            string rating = Console.ReadLine();

            newCar.SafetyRating = double.Parse(rating);

            Console.WriteLine("Enter the average annual emissions (metric tons):");
            string emissions = Console.ReadLine();

            newCar.Emissions = double.Parse(emissions);

            _carRepo.AddNewCar(newCar);
        }
        private void SeedData()
        {
            CarComparison nissanLeaf  = new CarComparison(CarType.Electric, "Nissan", "Leaf", 5.0, 0.0);
            CarComparison toyotaPrius = new CarComparison(CarType.Hybrid, "Toyota", "Prius", 5.0, 1.8);
            CarComparison vwJetta     = new CarComparison(CarType.Gas, "VW", "Jetta", 5.0, 4.6);

            _carRepo.AddNewCar(nissanLeaf);
            _carRepo.AddNewCar(toyotaPrius);
            _carRepo.AddNewCar(vwJetta);
        }
        private void UpdateExistingCar()
        {
            Console.Clear();

            ViewAllCars();

            Console.WriteLine("Which car would you like to update?");

            string oldCar = Console.ReadLine();

            CarComparison newCar = new CarComparison();

            Console.WriteLine("Enter the type of car:\n" +
                              "1. Electric\n" +
                              "2. Gas\n" +
                              "3. Hybrid");
            string typesAsString = Console.ReadLine();
            int    typesAsInt    = int.Parse(typesAsString);

            newCar.Types = (CarType)typesAsInt;
            Console.WriteLine(newCar.Types);

            Console.WriteLine("Enter the make:");
            newCar.SetMake(Console.ReadLine());

            Console.WriteLine("Enter the model:");
            newCar.SetModel(Console.ReadLine());

            Console.WriteLine("Enter the safety rating:");
            string rating = Console.ReadLine();

            newCar.SafetyRating = double.Parse(rating);

            Console.WriteLine("Enter the average annual emissions (metric tons):");
            string emissions = Console.ReadLine();

            newCar.Emissions = double.Parse(emissions);

            bool wasUpdated = _carRepo.UpdateExistingCar(oldCar, newCar);

            if (wasUpdated)
            {
                Console.WriteLine("Successful Update!");
            }
            else
            {
                Console.WriteLine("Date was not updated. Please try again.");
            }
        }
        public bool UpdateExistingCar(string originalCar, CarComparison newCar)
        {
            CarComparison oldCar = GetCarByFullName(originalCar);

            if (oldCar != null)
            {
                oldCar.Types        = newCar.Types;
                oldCar.CarName      = newCar.CarName;
                oldCar.SafetyRating = newCar.SafetyRating;
                oldCar.Emissions    = newCar.Emissions;

                return(true);
            }
            else
            {
                return(false);
            }
        }
        public bool RemoveCarFromList(string carName)
        {
            CarComparison car = GetCarByFullName(carName);

            if (car == null)
            {
                return(false);
            }

            int startingCount = _listofCars.Count;

            _listofCars.Remove(car);

            if (startingCount > _listofCars.Count)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 public void AddNewCar(CarComparison newCar)
 {
     _listofCars.Add(newCar);
 }