/// <summary> /// Get required information from staff's input to add a new movie to the Movie Collection or add a number of copies to an existing movie. /// </summary> /// <param name="collection"></param> static void AddMovie(MovieCollection collection) { string title = GetTitle(); if (collection.Find(title) == null) { Console.Write("Enter the starring actor(s): "); string starring_input = Console.ReadLine(); string[] starring = starring_input.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); Console.Write("Enter the director(s): "); string director_input = Console.ReadLine(); string[] director = director_input.Split(new string[] { ", " }, StringSplitOptions.RemoveEmptyEntries); Movie.Genre genre = getGenre(); Movie.Classification classification = getClassification(); Console.Write("Enter the duration (minutes): "); int duration = GetValue(); Console.Write("Enter the release year (year): "); int release_date = GetValue(); Console.Write("Enter the number of copies available: "); int copies = GetValue(); collection.Insert(new Movie(title, starring, director, duration, genre, classification, release_date, copies, 0)); } else { Console.Write("Enter the number of copies you would like to add: "); int value = GetValue(); collection.Add_copies(value, title); } }
/// <summary> /// Delete a movie from a member's record. /// </summary> /// <param name="username"></param> /// <param name="title"></param> /// <param name="storage"></param> public void Return(string username, string title, MovieCollection storage) { foreach (Member member in collection) { if (member.username == username && storage.Find(title) != null) { member.DeleteRecord(storage.Find(title)); } } }
static void Main(string[] args) { MovieCollection tree = new MovieCollection(); MemberCollection database = new MemberCollection(); int option; int option1; int option2; bool set = true; do { // Display the main menu to get the user's input option MainMenu(); option = GetOption(); if (option == FirstOption) { // Check the authentication of the user if (Authenticated()) { do { // Display the dedicated menu for staff SubMenu1(); // Get the staff's input option option1 = GetOption1(); // Call function that adds a movie with required details to the Movie Collection if (option1 == FirstOption) { AddMovie(tree); } // Call function that deletes a specific movie by name from the Movie Collection if (option1 == SecondOption) { Delete(tree); } // Call function that adds a member with required details to the Member Collection if (option1 == ThirdOption) { AddMember(database); } // Call function that finds a member's phone number if (option1 == FourthOption) { FindPhoneNumber(database); } } while (option1 != Back); } else { Console.Write("Wrong username or password!!!\n\n"); } } if (option == SecondOption) { var authentication = Verified(database); // Check the authentication of the user if (authentication.Item1) { do { // Display the dedicated menu for member SubMenu2(); // Get the member's input option option2 = GetOption2(); // Call function that displays a list of movie in the Movie Collection if (option2 == FirstOption) { tree.Inorder(); } // Call function that lets the member borrow a movie if (option2 == SecondOption) { Borrow(database, tree, authentication.Item2); } // Call function that lets the member return a movie if (option2 == ThirdOption) { Return(database, tree, authentication.Item2); } // Call function that displays a list of borrowed movie of the member if (option2 == FourthOption) { database.List(authentication.Item2); } // Call function that displays the most frequently borrowed movies if (option2 == FifthOption) { tree.Top10(); } } while (option2 != Back); } else { Console.Write("Wrong username or password!!!\n\n"); } } if (option == Back) { set = false; Quit(); } } while (set == true || option != Back); }