/// <summary> /// Supports input for borrowing movie /// </summary> /// <param name="movies">all available movies in Movie Collection</param> /// <returns>title of the movie that is selected by the member</returns> public static string Member2(Movie[] movies) { Console.WriteLine("\n=====Borrow movie====="); // display all movie title in the store for (int i = 0; i < movies.Length; i++) { Console.WriteLine("{0}. {1}", i + 1, movies[i].title); } // ask which title they want to borrow (input by number) int res = Reusables.waitUserResponse("Select by number: ", Reusables.createIntArray(1, movies.Length)); // return title return(movies[res - 1].title); }
/// <summary> /// Supports input for returning movie /// </summary> /// <param name="borrowing">All movies that the user is currently borrowing</param> /// <returns>title of movie to be returned</returns> public static string Member3(Movie[] borrowing) { Console.WriteLine("\n=====Return movie====="); // remove null value and create new array for easy handling Movie[] nullRemoved = new Movie[0]; foreach (Movie m in borrowing) { if (m != null) { Array.Resize(ref nullRemoved, nullRemoved.Length + 1); nullRemoved[nullRemoved.Length - 1] = m; } } for (int i = 0; i < nullRemoved.Length; i++) { Console.WriteLine("{0}. {1}", i + 1, nullRemoved[i].title); } // ask which title they want to borrow (input by number) int res = Reusables.waitUserResponse("Select by number: ", Reusables.createIntArray(1, nullRemoved.Length)); // return title return(nullRemoved[res - 1].title); }