Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program Requirements: Your program must have at least the following functions: 1. int numberOfLines(ifstream&); This function accepts an input file and returns an integer representing

Program Requirements: Your program must have at least the following functions: 1. int numberOfLines(ifstream&); This function accepts an input file and returns an integer representing the number of lines in the file 2. void populateMovieFromFile(ifstream&, Movie&); This function accepts an input file and a Movie object. Inside the function, a single line should be read in from the current read position of the input file. Once the line has been read in, it will be parsed and stored in the Movie object that was passed to the function. Notice that for a single call of populateMovieFromFile, only a single Movie object is populated. This means you will need to call it multiple times! 3. void displayMovie(const Movie&); This function accepts a Movie object passed by constant reference and displays the contents of that object in a formatted fashion (see sample run). 4. Movie* createDatabase(int&); As the name suggests, this function will be responsible for creating your movie database (which is just a dynamically-allocated array of Movie objects). The integer argument passed by reference to the function represents the number of movies in the database. It will not be initialized when you call the function, meaning its value will be set inside the body of the function. This function should: First, prompt the user to enter an input file name. If the name is invalid, display an error and continue to prompt them until a valid file name has been entered Determine the number of lines in the file using the numberOfLines function and create your dynamically-allocated array of Movie objects Loop through your newly-created array and store a movie in each index. This is where you will want to call your handy populateMovieFromFile function Populate the reference argument and return a pointer to the array of Movie objects 5. bool caseInsensitiveCmp(string, string); This function accepts two strings and performs a noncase-sensitive comparison on the two. If the two strings are the same, the function should return true; otherwise, it should return false. For example, if I pass the strings skyfall and SKYFALL to this function, it should return true. 6. void findMovie(Movie*, int); This function accepts a pointer to an array of Movie objects (your database), and the number of Movies (which is the same thing as the number of elements in the array). The function should: First, prompt the user to enter a movie title to search for Search through the array of Movie objects for the movie title If the movie was found, display the movie and ask the user if they would like to save the movie; if they choose yes, the movie will be saved to favorites.txt If the movie was not found, display an error message Notice that this function only prompts the user for a single movie and only performs a single search. This means you will be using it in a loop! 7. void saveToFile(const Movie&); This function accepts a Movie object, passed by constant reference. It should save the Movie object to the favorites.txt file. If the file does not exist, create it. If the file does exist, add the Movie object to the end of the file. Remember that you need to store the Movie object in the format: Movie title, Gross Total (in billions), Director, Release Date, Runtime (in minutes) 8. bool promptToContinue(); This function will determine whether or not the user wants to continue using the program. First, ask the user if they would like to exit the program and prompt them to either enter Y or N. If Y or y is entered, the function will return false (the user no longer wishes to continue); otherwise, return true. 9. void displayFavorites(); This function will display all saved favorite movies by displaying all the information in the favorites.txt file. If there are no saved movies, display an error; otherwise, simply display all saved movies.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Datalog Engines In Databases

Authors: Bas Ketsman ,Paraschos Koutris

1st Edition

1638280428, 978-1638280422

More Books

Students also viewed these Databases questions