Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Complete project
  • Loading branch information
krb11010 committed Feb 28, 2020
1 parent 1a1dc34 commit 67d5c9d
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions VehicleInventory/Program.cs
Expand Up @@ -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<Car> cars = FileHelper.GetCars(filepath);

while (true)
Expand All @@ -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();
Expand All @@ -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

}
}
}
Expand Down

0 comments on commit 67d5c9d

Please sign in to comment.