} //-end of ViewAllElectric()- // case 2 private void AddNewElectric() { Console.Clear(); ElectricClass newElectric = new ElectricClass(); // Make Console.WriteLine("Enter the make of the vehicle:"); newElectric.Make = Console.ReadLine().ToUpper(); // Model Console.WriteLine("Enter the model of the vehicle:"); newElectric.Model = Console.ReadLine(); // Year Console.WriteLine("Enter the year of the vehicle:"); string yearAsString = Console.ReadLine(); newElectric.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(); newElectric.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(); newElectric.Miles = int.Parse(milesAsString); _electricRepo.AddElectricToList(newElectric); } //-end of AddNewElectric()-
public void AddElectricToList_ShouldWork() { // Arrange ElectricRepo testRepo = new ElectricRepo(); ElectricClass newElectric = new ElectricClass { Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1 }; List <ElectricClass> _listOfElectrics = new List <ElectricClass>(); // Act _listOfElectrics.Add(newElectric); // Assert Assert.IsTrue(_listOfElectrics.Count > 0); }
} //-end of DeleteHybrid()- // case 10 private void UpdateExistingElectric() { Console.WriteLine("Enter the make of the vehicle you'd like to update:"); string oldMake = Console.ReadLine(); ElectricClass newMake = new ElectricClass(); // 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 = _electricRepo.UpdateExistingElectric(oldMake, newMake); if (wasUpdated) { Console.WriteLine("Vehicle successfully updated!"); } else { Console.WriteLine("Could not update vehicle."); } }
public void RemoveElectricFromList_ShouldWork() { ElectricRepo testRepo = new ElectricRepo(); ElectricClass newElectric = new ElectricClass { Make = "Mitsubishi", Model = "Lancer", Year = 4, Price = 2, Miles = 1 }; List <ElectricClass> _listOfElectrics = new List <ElectricClass>(); _listOfElectrics.Add(newElectric); int initialElectric = _listOfElectrics.Count; _listOfElectrics.Remove(newElectric); if (initialElectric > _listOfElectrics.Count) { Console.WriteLine("true"); } else { Console.WriteLine("false"); } }