static void Main(string[] args) { var restaurantPicker = new RestuarantPicker(); restaurantPicker.ReadRestaurantData(@"../../../restaurant_data.csv"); // Item is found in restaurant 2 at price 6.50 var bestRestaurant = restaurantPicker.PickBestRestaurant("tofu_log"); Console.WriteLine(bestRestaurant.Item1 + ", " + bestRestaurant.Item2); Console.WriteLine("Done!"); Console.ReadLine(); }
/// <summary> /// Takes in items you would like to eat and returns the best restaurant that serves them. /// </summary> /// <param name="items">Items you would like to eat (seperated by ',')</param> /// <returns>Restaurant Id and price tuple</returns> public Tuple <int, decimal> PickBestRestaurant(string items) { // Complete this method Tuple <int, decimal> tuple = new Tuple <int, decimal>(0, 0); var restaurantPicker = new RestuarantPicker(); restaurantPicker.ReadRestaurantData(@"../../../restaurant_data.csv"); foreach (var i in restaurantPicker._restaurants) { if (i.Menu.Keys.Contains(items)) { tuple = new Tuple <int, decimal>(i.RestaurantId, (from e in i.Menu where e.Key == items select e.Value).FirstOrDefault()); } } return(new Tuple <int, decimal>(tuple.Item1, tuple.Item2)); }