Ejemplo n.º 1
0
        /// <summary>
        /// Add a new movie title into the movie collection
        /// </summary>
        static void addMovie()
        {
            //Retrieve a new movie title and determine whether the movie title already exists in movie collection
            Console.Write("Movie title: ");
            string movieTitle     = Console.ReadLine();
            Movie  duplicateMovie = MovieCollection.Search(movieTitle);

            //If duplicate movie is found, ask to add additional copies instead
            if (duplicateMovie != null)
            {
                Console.WriteLine("Duplicate movie title found in movie collection!");
                Console.Write("How many additional copies would you like to add? ");
                duplicateMovie.movieCopies += Convert.ToInt32(Console.ReadLine());
            }
            else //if new movie doesn't exist in movie collection yet
            {
                //Add new movie to BST
                MovieCollection.Add(movieTitle);

                //Find the new movie in the collection
                Movie currentMovie = MovieCollection.Search(movieTitle);

                //Ask for additional info about the movie and update movie properties
                Console.Write("Starring actor(s): ");
                currentMovie.starringActor = Console.ReadLine();
                Console.Write("Director: ");
                currentMovie.director = Console.ReadLine();
                Console.Write("Duration (Minutes): ");
                currentMovie.duration = Convert.ToInt32(Console.ReadLine());
                Console.Write("Release Date (Year): ");
                currentMovie.releaseDate = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("\n1. Drama\n2. Adventure\n3. Family\n4. Action" +
                                  "\n5. Sci-Fi\n6. Comedy\n7. Animated\n8. Thriller\n9. Other");
                Console.Write("Genre (1 - 9): ");
                currentMovie.movieGenre = (Movie.Genre) int.Parse(Console.ReadLine());
                Console.WriteLine("\n1. General (G)\n2. Parental Guidance (PG)" +
                                  "\n3. Mature (M15+)\n4. Mature Accompanied (MA15+)");
                Console.Write("Classification (1 - 4): ");
                currentMovie.movieRating = (Movie.Classification) int.Parse(Console.ReadLine());

                Console.Write("Available copies: ");
                currentMovie.movieCopies = Convert.ToInt32(Console.ReadLine());

                Console.WriteLine("{0} has been added to the movie collection...", currentMovie.movieName);
            }
        }
Ejemplo n.º 2
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.º 3
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.º 4
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.º 5
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);
            }
        }