/// <summary> /// Staff menu /// </summary> static void StaffMenu() { if (!staffVerified) { StaffLogin(); } else { Console.WriteLine( "\n=============Staff Menu==========\n" + "1. Add a new movie DVD\n" + "2. Remove a movie DVD\n" + "3. Register a new Member\n" + "4. Find a registered member's phone number\n" + "0. Return to main menu\n" + "================================="); appStatus = (Reusables.waitUserResponse("\n Please make a selection (1-4 or 0 to return to main menu): ", new int[] { 0, 1, 2, 3, 4 })) switch { 0 => AppStatus.MainMenu, 1 => AppStatus.Staff1, 2 => AppStatus.Staff2, 3 => AppStatus.Staff3, 4 => AppStatus.Staff4, _ => AppStatus.MainMenu, }; } }
/// <summary> /// Helps input menu for staff to add a movie /// This simply create a movie object based on the input /// No duplication check /// </summary> /// <returns>Movie object</returns> public static Movie Staff1() { Console.WriteLine("\n=====Add Movie====="); Console.Write("Title: "); string title = Console.ReadLine(); Console.Write("Starring: "); string starring = Console.ReadLine(); Console.Write("Director: "); string director = Console.ReadLine(); int duration = Reusables.waitUserIntegerResponse("Duration(minutes): "); Genre genre = (Reusables.waitUserResponse("Genre:\n" + "1. Drama\n" + "2. Adventure\n" + "3. Family\n" + "4. Action\n" + "5. Sci-Fi\n" + "6. Comedy\n" + "7. Animated\n" + "8. Thriller\n" + "9. Other\n" + "Select: ", new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 })) switch { 1 => Genre.Drama, 2 => Genre.Adventure, 3 => Genre.Family, 4 => Genre.Action, 5 => Genre.SciFi, 6 => Genre.Comedy, 7 => Genre.Animated, 8 => Genre.Thriller, 9 => Genre.Other, _ => Genre.Other, }; Classification classification = (Reusables.waitUserResponse("Classification:\n" + "1. General (G)\n" + "2. Parental Guidance (PG)\n" + "3. Mature (M15+)\n" + "4. Mature Accompanies (MA15+)\n" + "Select: ", new int[] { 1, 2, 3, 4 })) switch { 1 => Classification.General, 2 => Classification.ParentalGuidance, 3 => Classification.Mature, 4 => Classification.MatureAccompanied, _ => Classification.General, }; int releaseDate = Reusables.waitUserIntegerResponse("Release date (year): "); int numCopies = Reusables.waitUserIntegerResponse("Number of copies: "); return(new Movie(title, starring, director, duration, genre, classification, releaseDate, numCopies)); }
/// <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> /// Member menu /// </summary> static void MemberMenu() { if (!memberVerified) { MemberLogin(); } else { Console.WriteLine( "\n==============Member Menu=========\n" + "1. Dispaly all movies\n" + "2. Borrow a movie DVD\n" + "3. Return a moive DVD\n" + "4. List current borrowed movie DVDs\n" + "5. Display top 10 most popular movies\n" + "0. Return to main menu\n" + "==================================="); switch (Reusables.waitUserResponse("\n Please make a selection (1-5 or 0 to return to main menu): ", new int[] { 0, 1, 2, 3, 4, 5 })) { case 0: appStatus = AppStatus.MainMenu; break; case 1: appStatus = AppStatus.Member1; break; case 2: appStatus = AppStatus.Member2; break; case 3: appStatus = AppStatus.Member3; break; case 4: appStatus = AppStatus.Member4; break; case 5: appStatus = AppStatus.Member5; break; default: appStatus = AppStatus.MainMenu; break; } } }
/// <summary> /// Landing page /// </summary> static void MainMenu() { staffVerified = false; memberVerified = false; Console.WriteLine( "\nWelcome to the Community Library\n" + "===========Main Menu============\n" + "1. Staff Login\n" + "2. Member Login\n" + "0. Exit\n" + "================================"); appStatus = (Reusables.waitUserResponse("\n Please make a selection (1-2, or 0 to exit): ", new int[] { 0, 1, 2 })) switch { 0 => AppStatus.Exit, 1 => AppStatus.StaffMenu, 2 => AppStatus.MemberMenu, _ => AppStatus.Exit, }; }
/// <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); }