コード例 #1
0
 public void DisplayCarList(KomodoGreenList carList)
 {
     Console.WriteLine($"List ID: {carList.CarListId}");
     Console.WriteLine($"List Type: {carList.CarListType}");
     Console.WriteLine("Cars in This List:");
     CarTableHeader();
     foreach (KomodoGreen car in carList.CarList)
     {
         string tableBody = String.Format("{0,-20} {1,-20} {2,-20} {3,-60}\n\n", car.ModelId, car.CarType, car.Name, car.Details);
         Console.WriteLine(tableBody);
     }
 }
コード例 #2
0
        public void CarListAdd()
        {
            Console.Clear();
            KomodoGreenList newCarList = new KomodoGreenList();

            Console.WriteLine("Enter the number assocated with the car list type you'd like to add.\n" +
                              "1. Electric\n" +
                              "2. Hybrid\n" +
                              "3. Gas");
            newCarList.CarListType = (CarListTypeEnum)int.Parse(Console.ReadLine());

            _carListRepo.CreateCarList(newCarList);

            Console.WriteLine("Your car list has been created. To add cars to this list, select the update car list option on the main menu.");
        }
コード例 #3
0
        public void Arrange()
        {
            _carRepo = new KomodoGreenRepo();
            _car1    = new KomodoGreen(CarTypeEnum.electric, "Tesla", "It's a Tesla.");
            _car2    = new KomodoGreen(CarTypeEnum.electric, "Zoom", "It's a Zoom.");
            _car3    = new KomodoGreen(CarTypeEnum.gas, "Ford", "It's a regular Ford.");

            _carRepo.AddCar(_car1);
            _carRepo.AddCar(_car2);

            _sampleListToAdd.Add(_car3);

            _listRepo = new KomodoGreenListRepo();
            _list1    = new KomodoGreenList(CarListTypeEnum.Electric);
            _list2    = new KomodoGreenList(CarListTypeEnum.Gas);

            _listRepo.CreateCarList(_list1);
        }
コード例 #4
0
        public void SeedData()
        {
            var A = new KomodoGreen(CarTypeEnum.electric, "Tesla", "The it car.");
            var B = new KomodoGreen(CarTypeEnum.hybrid, "Hyundai", "A reasonable car.");
            var C = new KomodoGreen(CarTypeEnum.gas, "Ford", "A normal truck.");
            var D = new KomodoGreen(CarTypeEnum.electric, "BMW", "Looks like it's from the future.");

            _carRepo.AddCar(A);
            _carRepo.AddCar(B);
            _carRepo.AddCar(C);
            _carRepo.AddCar(D);

            List <KomodoGreen> electricList = new List <KomodoGreen>();

            electricList.Add(A);
            electricList.Add(D);

            var A1 = new KomodoGreenList(CarListTypeEnum.Electric, electricList);
            var B1 = new KomodoGreenList(CarListTypeEnum.Gas);

            _carListRepo.CreateCarList(A1);
            _carListRepo.CreateCarList(B1);
        }
コード例 #5
0
        public void CarListUpdate()
        {
            Console.Clear();
            CarsListView();

            Console.WriteLine("Enter the ID of the car list you'd like to update");
            int             existingCarListId = int.Parse(Console.ReadLine());
            KomodoGreenList listToUpdate      = _carListRepo.GetCarListById(existingCarListId);

            Console.WriteLine($"What would you like to update in List ID {listToUpdate.CarListId}? Enter the corresponding number:\n" +
                              $"1. Add car(s) to list\n" +
                              $"2. Remove car from list.\n" +
                              $"3. Update car list type\n");

            string input = Console.ReadLine();

            switch (input)
            {
            case "1":
                CarsView();
                Console.WriteLine($"Please enter the model IDs of the cars you'd like to add to List ID {listToUpdate.CarListId} separated ONLY by commas.");
                List <string> listOfCarIdsAsString = Console.ReadLine().Split(',').ToList();

                var listOfCarsToAdd = new List <KomodoGreen>();

                foreach (string idAsString in listOfCarIdsAsString)
                {
                    int id = int.Parse(idAsString);

                    KomodoGreen carToAdd = _carRepo.GetCarByModelId(id);
                    listOfCarsToAdd.Add(carToAdd);
                }

                listToUpdate.AddCarToList(listOfCarsToAdd);

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");

                break;

            case "2":
                Console.WriteLine($"Please enter the model ID of the car you'd like to delete from List ID {listToUpdate.CarListId}.");
                listToUpdate.RemoveCarFromList(_carRepo.GetCarByModelId(int.Parse(Console.ReadLine())));

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");
                break;

            case "3":
                KomodoGreenList updatedCarList = new KomodoGreenList();

                Console.WriteLine("Enter the number assocated with the updated car list.\n" +
                                  "1. Electric\n" +
                                  "2. Hybrid\n" +
                                  "3. Gas");

                updatedCarList.CarListType = (CarListTypeEnum)int.Parse(Console.ReadLine());

                _carListRepo.UpdateCarList(listToUpdate.CarListId, updatedCarList.CarListType);

                Console.WriteLine("To view any changes to car lists, view all car lists in the main menu.");
                break;

            default:
                Console.WriteLine("You must enter a valid entry. You will be returned to the main menu.");
                break;
            }
        }