示例#1
0
        } //-end of ViewAllGas()-

        // case 5
        private void AddNewGas()
        {
            Console.Clear();

            GasClass newGas = new GasClass();

            // Make
            Console.WriteLine("Enter the make of the vehicle:");
            newGas.Make = Console.ReadLine().ToUpper();
            // Model
            Console.WriteLine("Enter the model of the vehicle:");
            newGas.Model = Console.ReadLine();
            // Year
            Console.WriteLine("Enter the year of the vehicle:");
            string yearAsString = Console.ReadLine();

            newGas.Year = int.Parse(yearAsString);
            // Price
            Console.WriteLine("How much did the vehicle cost? Do not use a dollar sign($). No commas needed.:");
            string priceAsString = Console.ReadLine();

            newGas.Price = int.Parse(priceAsString);
            // Miles
            Console.WriteLine("How many miles can it drive on a full tank of gas? (Numbers only please)");
            string milesAsString = Console.ReadLine();

            newGas.Miles = int.Parse(milesAsString);

            _gasRepo.AddGasToList(newGas);
        } //-end of AddNewGas()-
示例#2
0
        public void AddGasToList_ShouldWork()
        {
            GasRepo  testRepo = new GasRepo();
            GasClass newGas   = new GasClass {
                Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1
            };
            List <GasClass> _listOfGased = new List <GasClass>();

            // Act
            _listOfGased.Add(newGas);

            // Assert
            Assert.IsTrue(_listOfGased.Count > 0);
        }
示例#3
0
        // Here are some pre-made vehicles I want inside the app
        private void SeedMealList()
        {
            ElectricClass extesla   = new ElectricClass("TESLA", "Model X", 2020, 79990, 351);
            ElectricClass exnissan  = new ElectricClass("NISSAN", "LEAF", 2020, 31600, 226);
            ElectricClass exjaguar  = new ElectricClass("JAGUAR", "I-PACE", 2020, 69850, 234);
            GasClass      exhonda   = new GasClass("HONDA", "Civic", 2021, 22000, 40);
            GasClass      exhyundai = new GasClass("HYUNDAI", "Elantra", 2020, 19300, 41);
            GasClass      extoyota  = new GasClass("TOYOTA", "Avalon", 2021, 35875, 34);
            HybridClass   exkia     = new HybridClass("KIA", "Optima", 2021, 30490, 32);

            _electricRepo.AddElectricToList(extesla);
            _electricRepo.AddElectricToList(exnissan);
            _electricRepo.AddElectricToList(exjaguar);
            _gasRepo.AddGasToList(exhonda);
            _gasRepo.AddGasToList(exhyundai);
            _gasRepo.AddGasToList(extoyota);
            _hybridRepo.AddHybridToList(exkia);
        }
示例#4
0
        // case 11
        private void UpdateExistingGas()
        {
            Console.WriteLine("Enter the make of the vehicle you'd like to update:");
            string   oldMake = Console.ReadLine();
            GasClass newMake = new GasClass();

            // Make
            Console.WriteLine("Enter the make of the vehicle:");
            newMake.Make = Console.ReadLine().ToUpper();
            // Model
            Console.WriteLine("Enter the model of the vehicle:");
            newMake.Model = Console.ReadLine();
            // Year
            Console.WriteLine("Enter the year of the vehicle:");
            string yearAsString = Console.ReadLine();

            newMake.Year = int.Parse(yearAsString);
            // Price
            Console.WriteLine("How much did the vehicle cost? Do not use a dollar sign($). No commas needed.:");
            string priceAsString = Console.ReadLine();

            newMake.Price = int.Parse(priceAsString);
            // Miles
            Console.WriteLine("How many miles can it drive on a fully charged battery? (Numbers only please)");
            string milesAsString = Console.ReadLine();

            newMake.Miles = int.Parse(milesAsString);

            bool wasUpdated = _gasRepo.UpdateExistingGas(oldMake, newMake);

            if (wasUpdated)
            {
                Console.WriteLine("Vehicle successfully updated!");
            }
            else
            {
                Console.WriteLine("Could not update vehicle.");
            }
        }
示例#5
0
        public void RemoveGasFromList_ShouldWork()
        {
            GasRepo  testRepo = new GasRepo();
            GasClass newGas   = new GasClass {
                Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1
            };
            List <GasClass> _listOfGased = new List <GasClass>();

            _listOfGased.Add(newGas);

            int initialGas = _listOfGased.Count;

            _listOfGased.Remove(newGas);

            if (initialGas > _listOfGased.Count)
            {
                Console.WriteLine("true");
            }
            else
            {
                Console.WriteLine("false");
            }
        }