From 67d5c9d2c5b2dea774db53ff5f3c589ffbc074a6 Mon Sep 17 00:00:00 2001 From: Kevin Brown Date: Thu, 27 Feb 2020 19:15:45 -0500 Subject: [PATCH] Complete project --- VehicleInventory/Program.cs | 45 ++++++++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/VehicleInventory/Program.cs b/VehicleInventory/Program.cs index ddc9375..42ee083 100644 --- a/VehicleInventory/Program.cs +++ b/VehicleInventory/Program.cs @@ -8,7 +8,7 @@ namespace VehicleInventory { static void Main(string[] args) { - string filepath = @"C:\Users\krb11010\Downloads\VehicleInventory.csv"; + string filepath = @"/Volumes/krb11010/3220/CarInventory-Complete/VehicleInventory.csv"; List cars = FileHelper.GetCars(filepath); while (true) @@ -17,7 +17,7 @@ namespace VehicleInventory Console.WriteLine("Input the number for what you're trying to search by:"); Console.WriteLine("1 - Search by manufacturer"); Console.WriteLine("2 - Search by year"); - Console.WriteLine("3 - Searcy by mileage range"); + Console.WriteLine("3 - Search by mileage range"); Console.WriteLine("4 - Search by price range"); Console.WriteLine("10 - Exit"); string action = Console.ReadLine(); @@ -32,17 +32,56 @@ namespace VehicleInventory searchResult = cars.Where(w => w.Make == make).ToList(); break; case "2": + Console.WriteLine("What year vehicle is the customer interested in?"); + double year = Convert.ToDouble(Console.ReadLine()); + + searchResult = cars.Where(w => w.Year == year).ToList(); break; case "3": + Console.WriteLine("What is the minimum number of acceptable miles?"); + double mileMinimum = Convert.ToDouble(Console.ReadLine()); + + Console.WriteLine("What is the maximum number of acceptable miles?"); + double mileMaximum = Convert.ToDouble(Console.ReadLine()); + + searchResult = cars.Where(w => w.Mileage >= mileMinimum && w.Mileage <= mileMaximum).ToList(); break; case "4": + Console.WriteLine("What is the minimum price the customer wants to pay?"); + decimal priceMinimum = Convert.ToDecimal(Console.ReadLine()); + + Console.WriteLine("What is the maximum price the customer wants to pay?"); + decimal priceMaximum = Convert.ToDecimal(Console.ReadLine()); + + searchResult = cars.Where(w => w.Price >= priceMinimum && w.Price <= priceMaximum).ToList(); break; case "10": + Environment.Exit(0); break; default: - break; + Console.WriteLine("Please input a valid response. Hit return to try again..."); + Console.ReadLine(); + continue; // Start over, don't display results } + if (searchResult.Count > 0) + { + Console.Clear(); + Console.WriteLine("Search Results"); + Console.WriteLine(); + + foreach (Car car in searchResult) + { + Console.WriteLine(car.GetDetails()); + } + + Console.WriteLine(); + Console.WriteLine("Press return to search again"); + Console.ReadLine(); + } + + // else No results, try again + } } }