Ejemplo n.º 1
0
        /// <summary>
        /// Member menu input handling
        /// </summary>
        static void menuInput()
        {
            int response = int.Parse(Console.ReadLine());

            switch (response)
            {
            case 1:
                Console.WriteLine("\nDisplaying all movies...");
                MovieCollection.inOrder();
                menuFunctions();
                break;

            case 2:
                Console.WriteLine("\nBorrow a movie DVD...");
                borrowMovie();
                menuFunctions();
                break;

            case 3:
                Console.WriteLine("\nReturn a movie DVD...");
                returnBorrowedMovie();
                menuFunctions();
                break;

            case 4:
                Console.WriteLine("\nCurrent borrowed movie DVDs...");
                MemberMovies.showBorrowedMovies();
                menuFunctions();
                break;

            case 5:
                Console.WriteLine("\nTop 10 most popular movies...");
                MovieCollection.top10Borrowed();
                menuFunctions();
                break;

            default:
                Console.WriteLine("\nReturning to menu...");
                MainMenu.mainMenu();
                break;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Allows a member to borrow a movie from the movie collection and updates their movie records
        /// </summary>
        public static void borrowMovie()
        {
            Console.Write("What movie would you like to borrow? ");
            string borrowMovieTitle = Console.ReadLine();

            //determine if movie has been previously borrowed by current member
            if (MemberMovies.checkBorrowed(borrowMovieTitle))
            {
                Console.WriteLine("You have already borrowed {0}...", borrowMovieTitle);
            }
            //if member is about to exceed number of loaned movies limit
            else if (verifiedMember.borrowedMovies.Count == 10)
            {
                Console.WriteLine("You already have 10 movies borrowed. Cannot borrow anymore movies.");
            }
            else //if movie hasn't been borrowed by this member
            {
                //attempt to find the given movie title in the collection
                Movie loanedMovie = MovieCollection.Search(borrowMovieTitle);

                //given movie couldn't be found
                if (loanedMovie == null)
                {
                    Console.WriteLine("{0} does not exist in library...", borrowMovieTitle);
                }
                //no more copies available to loan out
                else if (loanedMovie.movieCopies == 0)
                {
                    Console.WriteLine("Sorry, there are no more copies of {0}...", borrowMovieTitle);
                }
                else //movie could be found - remove a copy from the movie collection and add to member's movie record
                {
                    loanedMovie.movieCopies--;
                    loanedMovie.timesRented++;
                    MemberMovies.addMovie(loanedMovie);
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the given movie from the BST
        /// Also deletes the all copies of the movie from every member's movie record
        /// </summary>
        static void deleteMovie()
        {
            //Retrieve movie title to remove and check if that movie exists in the movie collection
            Console.Write("Enter a movie title to remove from the collection: ");
            string removeMovieTitle = Console.ReadLine();
            Movie  removedMovie     = MovieCollection.Search(removeMovieTitle);


            //Couldn't find the intended movie to delete
            if (removedMovie == null)
            {
                Console.WriteLine("{0} does not exist in collection to delete...", removeMovieTitle);
            }
            else //if the movie could be found
            {
                //remove all instances of that movie from all member movie collections
                MemberMovies.deleteLoanedMovies(removeMovieTitle);
                //remove movie from main movie collection
                MovieCollection.Delete(removedMovie);
                //remove movie from stored movie array
                MovieCollection.removeMovie(removedMovie);
                Console.WriteLine("You have successfully removed {0}...", removeMovieTitle);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Allows a verified member to return a movie from their movie records
        /// </summary>
        public static void returnBorrowedMovie()
        {
            Console.Write("What movie would you like to return? ");
            string loanedMovieTitle = Console.ReadLine();

            //check if the member has borrowed the movie
            if (MemberMovies.checkBorrowed(loanedMovieTitle))
            {
                //remove the loaned movie from the member's movie record
                MemberMovies.returnMovie(loanedMovieTitle);
                Console.WriteLine("You have successfully returned {0}", loanedMovieTitle);

                //Return a copy of the movie to the movie collection (if movie hasn't been deleted from movie collection)
                Movie returnedMovie = MovieCollection.Search(loanedMovieTitle);
                if (returnedMovie != null)
                {
                    returnedMovie.movieCopies++;
                }
            }
            else //given movie title doesn't exist in the member's movie record
            {
                Console.WriteLine("You don't have the movie {0} to return...", loanedMovieTitle);
            }
        }