/// <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); } } }
/// <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); } }