//Returns information about the top ten most borrowed movies in the library //Input: None //Output: Outputs the movies in a ranking system from 1. to 10. based on the // amount of times they have been borrowed static void TopTen() { int size = _library.Size(); if (size > 10) { size = 10; } int.TryParse(Math.Ceiling(size / 5.0).ToString(), out int pages); int currentPage = 1; DisplayTopTen: Console.Clear(); Console.WriteLine("Logged in as {0} {1}", _current.FirstName, _current.Surname); Console.WriteLine("=======Display top 10 most popular movies======="); MovieCollection top = _library.Subcollection(0, size, "top"); top = top.Subcollection((currentPage - 1) * 5, (currentPage) * 5, "top"); top.Display(currentPage); Console.Write("\n Page: 0 (Return)"); for (int i = 1; i <= pages; i++) { if (i == currentPage) { Console.Write(" [{0}]", i.ToString()); } else { Console.Write(" {0} ", i.ToString()); } } Console.WriteLine("\n================================================"); ConsoleKeyInfo c = Console.ReadKey(true); if (c.Key == ConsoleKey.Escape) { return; } if (c.KeyChar.ToString() == "0") { return; } int.TryParse(c.KeyChar.ToString(), out int v); if (v > 0 && v <= pages) { currentPage = v <0 ? 0 : v> pages ? pages : v; } goto DisplayTopTen; }
//Displays movies in pages of 2, with information about each movie //Input: Page number selection or return //Output: Display movie data from that page static void DisplayMovies() { int size = _library.Size(); int.TryParse(Math.Ceiling(size / 2.0).ToString(), out int pages); int currentPage = 1; DisplayMovies: Console.Clear(); Console.WriteLine("Logged in as {0} {1}", _current.FirstName, _current.Surname); Console.WriteLine("===============Display all movies==============="); MovieCollection currentMovies = _library.Subcollection(((currentPage - 1) * 2), ((currentPage) * 2)); currentMovies.Display(); Console.Write("\n Page: 0 (Return)"); for (int i = 1; i <= pages; i++) { if (i == currentPage) { Console.Write(" [{0}]", i.ToString()); } else { Console.Write(" {0} ", i.ToString()); } } Console.WriteLine("\n================================================"); ConsoleKeyInfo c = Console.ReadKey(true); if (c.Key == ConsoleKey.Escape) { return; } if (c.KeyChar.ToString() == "0") { return; } int.TryParse(c.KeyChar.ToString(), out int v); if (v > 0 && v <= pages) { currentPage = v <0 ? 0 : v> pages ? pages : v; } goto DisplayMovies; }