Ejemplo n.º 1
0
        private void AddCarToList()
        {
            Car_Comparisons car = new Car_Comparisons();

            Console.WriteLine("What type of car is it?\n" +
                              "1. Gas\n" +
                              "2. Electrc\n" +
                              "3. Hybrid");

            string InputAsString = Console.ReadLine();
            int    carType       = int.Parse(InputAsString);

            switch (carType)
            {
            case 1:
                car.TypeOfFuel = FuelType.Gas;
                break;

            case 2:
                car.TypeOfFuel = FuelType.Electric;
                break;

            case 3:
                car.TypeOfFuel = FuelType.Hybrid;
                break;
            }

            Console.WriteLine("What model is the car?");
            string model = Console.ReadLine();

            Console.WriteLine("What Year is the car?");
            string yearOfCar = Console.ReadLine();

            Console.WriteLine("What Color is the car?");
            string colorOfCar = Console.ReadLine();

            if (car.TypeOfFuel == FuelType.Gas)
            {
                _cars_Repository.AddCarToList(car, gas);
            }

            if (car.TypeOfFuel == FuelType.Hybrid)
            {
                _cars_Repository.AddCarToList(car, hybrid);
            }
            if (car.TypeOfFuel == FuelType.Electric)
            {
                _cars_Repository.AddCarToList(car, electric);
            }
        }
Ejemplo n.º 2
0
        private void RemoveCarFromList()
        {
            Car_Comparisons car = new Car_Comparisons();

            Console.WriteLine("What car would you like to Remove?\n" +
                              "1. Gas\n" +
                              "2. Electric\n" +
                              "3. Hybrid.");

            string asString  = Console.ReadLine();
            int    removeCar = int.Parse(asString);

            List <Car_Comparisons> selectedList = gas;


            switch (removeCar)
            {
            case 1:
                SeeAll(gas, "gas");
                selectedList = gas;
                break;

            case 2:
                SeeAll(electric, "electric");
                selectedList = electric;
                break;

            case 3:
                SeeAll(hybrid, "hybrid");
                selectedList = hybrid;
                break;
            }

            Console.WriteLine("Which car do you want to remove?");
            string carToRemove = Console.ReadLine();
            int    removeCarAt = int.Parse(carToRemove) - 1;

            selectedList.RemoveAt(removeCar);
        }
Ejemplo n.º 3
0
 public void RemoveCarFromList(Car_Comparisons car, List <Car_Comparisons> list)
 {
     list.Remove(car);
 }
Ejemplo n.º 4
0
 public void AddCarToList(Car_Comparisons car, List <Car_Comparisons> list)
 {
     list.Add(car);
 }
Ejemplo n.º 5
0
        private void UpdateInformation()
        {
            Console.WriteLine("Which car list do you want to update?\n" +
                              "1. Gas\n" +
                              "2. Electric\n" +
                              "3. Hybrid.");

            string update                       = Console.ReadLine();
            int    updateInformation            = int.Parse(update);
            List <Car_Comparisons> selectedList = gas;


            switch (updateInformation)
            {
            case 1:
                SeeAll(gas, "gas");
                selectedList = gas;
                break;

            case 2:
                SeeAll(electric, "electric");
                selectedList = electric;
                break;

            case 3:
                SeeAll(hybrid, "hybrid");
                selectedList = hybrid;
                break;
            }

            Console.WriteLine("Which car do you want to update?");
            string carToUpdate = Console.ReadLine();
            int    updateCar   = int.Parse(carToUpdate) - 1;

            Car_Comparisons car = selectedList.ElementAt(updateCar);

            Console.WriteLine("Do you want to update the Car Type?\n" +
                              "Yes\n" +
                              "OR\n" +
                              "No?");
            string updateCarType = Console.ReadLine();

            if (updateCarType == "Y")
            {
                Console.WriteLine("Enter car type");
                string updatedType = Console.ReadLine();
                car.CarType = updatedType;
            }

            Console.WriteLine("Do you want to update the Car Year?\n" +
                              "Yes\n" +
                              "OR\n" +
                              "No.?");
            string updateCarYear = Console.ReadLine();

            if (updateCarYear == "Y")
            {
                Console.WriteLine("Enter Car Year");
                string updateYear = Console.ReadLine();
                car.Year = int.Parse(updateYear);
            }

            Console.WriteLine("Do you want to update the Car Color?\n" +
                              "Yes\n" +
                              "OR\n" +
                              "No?");
            string updateCarColor = Console.ReadLine();

            if (updateCarColor == "Y")
            {
                Console.WriteLine("Enter Car Color");
                string updatedColor = Console.ReadLine();
                car.Color = updatedColor;
            }
        }