Пример #1
0
        private static void RemoveMovieStaff2(MovieCollection movieList, MemberCollection memberList)
        {
            Console.Write("Enter movie title: ");
            string removeTitle = Console.ReadLine();
            Movie  checkExist  = null;

            // search only if root is not null
            if (movieList.root != null)
            {
                checkExist = movieList.SearchMovie(movieList.root, removeTitle);
            }

            if (checkExist != null)
            {
                for (int i = 0; i < memberList.GetNumMembers(); i++)
                {
                    memberList.GetMember(i).ReturnDVD(checkExist);
                }
                movieList.Remove(checkExist);
                Console.WriteLine("You removed {0}", checkExist.GetTitle());
            }
            else
            {
                Console.WriteLine("No movies to remove!");
            }
        }
Пример #2
0
        private static void ReturnDVDMember3(MovieCollection movieList, Member member)
        {
            Console.Write("Enter movie title: ");
            string returnTitle  = Console.ReadLine();
            Movie  toBeReturned = movieList.SearchMovie(movieList.root, returnTitle);

            if (toBeReturned != null)
            {
                toBeReturned.ReturnItem();
                member.ReturnDVD(toBeReturned);
                Console.WriteLine("You returned {0}\n", toBeReturned.GetTitle());
            }
            else
            {
                Console.WriteLine("Cannot return movie!\n");
            }
        }
Пример #3
0
        private static void BorrowDVDMember2(MovieCollection movieList, Member member)
        {
            Console.Write("Enter movie title: ");
            string borrowTitle  = Console.ReadLine();
            Movie  toBeBorrowed = movieList.SearchMovie(movieList.root, borrowTitle);

            if (toBeBorrowed != null && toBeBorrowed.GetCopies() != 0)
            {
                toBeBorrowed.BorrowItem();
                member.RentDVD(toBeBorrowed);
                Console.WriteLine("You borrowed {0}\n", toBeBorrowed.GetTitle());
            }
            else
            {
                Console.WriteLine("Cannot borrow movie!\n");
            }
        }
Пример #4
0
        private static void AddMovieStaff1(MovieCollection movieList)
        {
            Console.Write("Enter the movie title: ");
            string title = Console.ReadLine();

            Movie checkExist = null;

            // search only if root is not null
            if (movieList.root != null)
            {
                checkExist = movieList.SearchMovie(movieList.root, title);
            }
            // already exists
            if (checkExist != null)
            {
                Console.Write("Enter the number of copies you would like to add: ");
                Int32.TryParse(Console.ReadLine(), out int addCopies);
                checkExist.AddCopies(addCopies);
                Console.WriteLine("Added {0} new copies of {1}\n", addCopies, movieList.SearchMovie(movieList.root, title).GetTitle());
            }
            else
            {
                Console.Write("Enter the starring actor(s): ");
                string starring = Console.ReadLine();
                Console.Write("Enter the director(s): ");
                string director = Console.ReadLine();

                Dictionary <int, string> genres = new Dictionary <int, string>
                {
                    { 1, "Drama" }, { 2, "Adventure" }, { 3, "Family" }, { 4, "Action" },
                    { 5, "Sci-Fi" }, { 6, "Comedy" }, { 7, "Thriller" }, { 8, "Other" },
                };
                Console.WriteLine("Select the genre:");
                foreach (var pair in genres)
                {
                    Console.WriteLine("{0}. {1}", pair.Key, pair.Value);
                }
                Console.Write("Make selection (1-8): ");
                Int32.TryParse(Console.ReadLine(), out int selectedGenre);

                Dictionary <int, string> classifications = new Dictionary <int, string> {
                    { 1, "General (G)" }, { 2, "Parental Guidance (PG)" }, { 3, "Mature (M15+)" }, { 4, "Mature Accompanied (MA15+)" }
                };
                Console.WriteLine("Select the classification:");
                foreach (var pair in classifications)
                {
                    Console.WriteLine("{0}. {1}", pair.Key, pair.Value);
                }
                Console.Write("Make selection (1-4): ");
                Int32.TryParse(Console.ReadLine(), out int selectedClassification);

                Console.Write("Enter the duration (minutes): ");
                Int32.TryParse(Console.ReadLine(), out int duration);

                Console.Write("Enter the release date (year): ");
                Int32.TryParse(Console.ReadLine(), out int year);

                Console.Write("Enter the number of copies available: ");
                Int32.TryParse(Console.ReadLine(), out int copies);


                Movie newMovie = new Movie
                                     (title, director, starring, genres[selectedGenre], classifications[selectedClassification], duration, year, copies);
                movieList.Insert(newMovie);
            }
        }