public void SortByNameAscending() { Restaurant res1 = new Restaurant("Burger King", 1); Restaurant res2 = new Restaurant("McDonalds", 2); Restaurant res3 = new Restaurant("Wendys", 3); Restaurant res4 = new Restaurant("Checkers", 4); Reviewer reviewer = new Reviewer("Cooper", "*****@*****.**"); reviewer.MakeReview(4.35m, res1, "I really liked it"); reviewer.MakeReview(3.67m, res2, "It was ok"); reviewer.MakeReview(4.87m, res3, "Sooooo good"); reviewer.MakeReview(2.34m, res4, "holy crap so bad"); List <Restaurant> myList = new List <Restaurant>(); myList.Add(res1); myList.Add(res2); myList.Add(res3); myList.Add(res4); List <Restaurant> sortedList = RestaurantListMethods.SortByNameAscending(myList); int expected = 1; int actual = sortedList.IndexOf(res4); Assert.AreEqual(expected, actual); }
public ActionResult NameAscending() { List<Restaurant> myRest = resCrud.GetAllRestaurant(); List<Restaurant> nameAscendingList = resMethods.SortByNameAscending(myRest); TempData["nameAscendingList"] = nameAscendingList; return RedirectToAction("index"); }
static void Main(string[] args) { //Restaurant res = new Restaurant("Papa Johns"); //RestaurantSerializer resSerializer = new RestaurantSerializer(); //resSerializer.SerializeMethod(res, "restaurant2"); //RestaurantDeserializer resDeserializer = new RestaurantDeserializer(); //Console.WriteLine(resDeserializer.DeserializeMethod("restaurant2").AverageRating); //Console.ReadKey(); //Logger log = LogManager.GetCurrentClassLogger(); //log.Info("Starting application"); //// start application //Console.WriteLine("Welcome to the world of restaurants"); //Console.WriteLine("-----------------------------------"); //Console.WriteLine(); //// display menu //Console.WriteLine("Here are your options bud: "); //Console.WriteLine("\"ViewRev\" (View all restaurants)"); //Console.WriteLine("\"TopThree\" (Return the top 3 restaurants)"); //Console.WriteLine("\"ViewRes\" (View a reviews)"); //Console.WriteLine("\"AddRes\" (Add a restaurant)"); //Console.Write("Your input: "); //String input = Console.ReadLine().ToLower(); //while(input != "quit") //{ // if(input == "viewres") // { // Console.WriteLine("How would you like to find the restaurant?"); // } // else if(input != "viewres" && input != "topthree" && input != "viewrev" && input != "addres") // { // Console.WriteLine("You messed up bud. Please enter either \"ViewRev\", \"TopThree\", \"ViewRes\", or \"AddRes\""); // Console.Write("<input> "); // input = Console.ReadLine().ToLower(); // log.Info(input); // } //} //// end application //Console.WriteLine("peace out dude"); RestaurantCRUD resCrud = new RestaurantCRUD(); List <RestaurantLibrary.Models.Restaurant> resList = new List <RestaurantLibrary.Models.Restaurant>(RestaurantListMethods.CreateRestaurantList(resCrud.GetRestaurant())); foreach (RestaurantLibrary.Models.Restaurant res in resList) { Console.WriteLine(res.Name); Console.WriteLine(res.AverageRating); Console.WriteLine(res.Location); res.getAllReviews(); } ; RestaurantListMethods.TopThree(resList); RestaurantListMethods.SortByNameAscending(resList); RestaurantListMethods.SortByNameDescending(resList); Console.ReadKey(); }