Question
I need help with my Computer Science 2 project. The stdafx.h file is the only one I need help with. When I use stdafx.h for
I need help with my Computer Science 2 project. The stdafx.h file is the only one I need help with. When I use stdafx.h for one of my headers, the program terminates.
Develop a high-quality, menu-driven object-oriented C++ program that creates a small database, using a binary search tree structure to store and process the data. The database will contain the top 100 highest grossing films of 2015.
The C++ object-oriented program must use the BinarySearchTree class from the textbook (along with the BinaryNode, BinaryNodeTree, BinaryTreeInterface, NotFoundException,and PrecondViolatedExcep classes it requires) to fulfill the requirements of this project. When designing and implementing the program, apply good software engineering principles. Create a makefile for the program that allows compilation and execution of the program from within jGRASP using the Windows operating system. Start the analysis and design process by drawing a complete UML class diagram for the program that includes all the classes that are contained in the program, including the classes provided by the textbook and the classes that you create. The UML class diagram will assist you in understanding the components of the project.
Your program must include:
a Film class that stores all the data for a Film and provides appropriate methods to support good software engineering principles,
a FilmDatabase class that stores the binary search tree and provides appropriate methods to support good software engineering principles,
a Menu class that contains, as a minimum, a method for each menu used in the program that displays the menu and responds to all menu choices made by the user, calling appropriate methods in the FilmDatabase class as necessary, and
a file named Project1.cpp that contains the main() method.
You may also include other classes, as needed. Note that the binary search tree must store Film objects, and the >, <, and == operators must be defined for that class because the BinarySearchTree class uses those overloaded operators.
The downloaded files include the Student class (Student.h and Student.cpp), the StudentDatabase class (StudentDatabase.h and StudentDatabase.cpp), BSTTest.cpp, and makefile for you to use as an example to help you begin your program. The program compiles, links, and executes if you Make it using jGRASP/Windows.
Data Details:
The database contains data pertaining to the 100 highest grossing films of 2015. A comma delimited file named Films2015.csv contains the initial data. Each record is stored on one line of the file in the following format:
Data Data type
Rank int
Film Title (key) string
Studio string
Total Gross double
Total Theaters int
Opening Gross double
Opening Theaters int
Opening Date string
Each of the data fields is separated in the file using the comma (,) character as a delimiter. There is no comma (,) character after the last field on the line. The data is considered clean; There are no errors in the input file.
When storing the data in the binary search tree, use the data types shown above. The Film Title will serve as the key field (its value is unique).
Menu Details:
Your program must begin by inputting the text data from the Films2015.csv text file and building a binary search tree for the Films, in order by the key (the film title). Then the program must display the following Main Menu:
MAIN MENU
D - Describe the Program
R Reports
S - Search the Database
X - Exit the Program
Enter Selection ->
All menu choices are selected by typing the number of the choice.
D - Describe the Program
If the user chooses Describe the Program, the program provides a detailed description for the user, explaining what the program is doing and how it works. Note that this method does NOT substitute for javadoc-style comments. The audience for this method consists of non-technical users that have no information at all about the assignment. After providing the description, display the MAIN MENU again. Do NOT use recursion to do this; use a loop.
R - Reports
If the user chooses Reports from the MAIN MENU, the program displays the following menu:
REPORTS MENU T - Order by Film Title report R - Order by Rank report X - Return to main menu
Enter Selection ->
If the user chooses Order by Film Title report from the REPORTS MENU, the program should do the following:
Display a report in order by Film Title that contains all the data for each record stored in the binary search tree.
Identify the report and label all the data displayed appropriately. The following is a sample output (Assume there are only 10 nodes in the tree):
If the user chooses Order by Rank report from the REPORTS MENU, the program should do the following:
Display a report sorted in increasing order by earnings rank that contains all the data for each record stored in the binary search tree. Note that this does not involve a simple tree traversal or single method call. You will need to write code that specifically performs this function. You may assume that the rank is never less than 1 and never greater than 100. Do NOT copy the data into another binary search tree, into an array, into a linked list, vector or into any other type of data structure. Retrieve the data directly from the binary search tree which is stored in order by the Film Title.
Identify the report and label all the data displayed appropriately. The following is the sample output:
If the user chooses Return to main menu from the REPORTS MENU, then display the MAIN MENU again. Do NOT use recursion to do this; use a loop.
S - Search the Database
If the user chooses Search the database, the program should display another menu, as follows:
Search Menu
T - Search by Title
K - Search by Keyword(s)
S - Search by Studio
M - Search by month of release
X - Return to main menu
Enter Selection ->
If the user chooses Search by Title, the program should do the following:
Request a film title from the user.
Search the database for the title given. This will be an exact match of the film title and at most, only 1 record will match. A case insensitive search should be performed.
If the film title is found, display the record stored in the binary search tree. Otherwise report that the requested film title was not found.
Identify the output and label all the data displayed appropriately.
If the user chooses Search by Keyword(s), the program should do the following:
Request title keywords from the user.
Search the database for all titles that contain the keyword(s). The keywords given represent all or a portion of the title. When multiple keywords are given, only titles that contain the keywords in the order given will be selected. For example, if the user enters Star Wars, Star Wars: The Force Awakens will be selected as will The Making of Star Wars. However, One Star, Many Wars, Once Upon a Star, Wars and Wars with Stars will not be selected.
Multiple search keywords may be entered by separating the keywords with a comma. All titles containing one or more of the keywords will be selected. For example, if the user enters 'Cinderella,SpongeBob,Dinosaur', "Cinderella", "The Good Dinosaur", "In Search of Dinosaurs", "The SpongeBob Movie: Sponge Out of Water" as well as "Cinderella Loves Dinosaurs and SpongeBob!" will be selected.
Display all records stored in the binary search tree where the title contains the keyword(s) given by the user. If there are no records containing the keyword(s), report that the requested keyword(s) were not found.
Identify the output and label all the data displayed appropriately.
If the user chooses Search by Studio, the program should do the following:
Request the name of a Studio from the user.
Search the database for an exact match of the studio name.
Display all records stored in the binary search tree where the studio name matches the name given by the user. If there are no records with the studio name given, report that the requested studio was not found.
Identify the output and label all the data displayed appropriately.
If the user chooses Search by month of release, the program should do the following:
Request a month value between 1 and 12 from the user.
Search the database for all records where the release date contains the month requested. Note: the date is stored as a string.
Display all records stored in the binary search tree that match the month given by the user. If there are no records with the requested release month, report that the requested month was not found.
Identify the output and label all the data displayed appropriately.
If the user chooses Return to main menu, then display the MAIN MENU again. Do NOT use recursion to do this; use a loop.
X Exit the Program
If the user chooses Exit the Program from the MAIN MENU, the program ends.
Since the program is controlled and manipulated by a human user, be sure to perform adequate error checking on every aspect of the program.
Be sure to follow the Project Guidelines & Evaluation Criteria, since the project will be evaluated using this criteria. In addition, be sure to use javadoc-style comments appropriately. When creating javadoc-style comments, keep in mind that the comment will eventually become part of an html file that will be used by other programmers on your programming team, and by maintenance programmers. Remember also that maintenance programmers have not seen the assignment (the specification), so the information you are providing here must provide all of the detailed information another programmer will need to completely understand the program and to maintain the code.
******************** Stdafx.h ********************
******************** Movie.cpp ********************
//Include required library files #include "stdafx.h" #include #include #include #include
//use namespace using namespace std;
//Define structure named Movie struct MovieData { //Declare hetrogeneous elements int rank; string FilmTitle; string Studio; double TotalGross; int TotalTheaters; double OpeningGross; int OpeningTheaters; string OpeningDate; };
//Define class Movie class Movie { public: //Declare the essential methods char describe(); void sortRankReport(); void sortTitleReport(); };
//Class Menu displays all the methods used //to display menu class Menu { public: //Declare the essential methods char getmenu(); char getReport(); char getSearch(); void setReport(char ch); void setSearch(char ch); };
//Class FilmDatabase contains all the methods //to search in the class class FilmDatabase { public: //Declare the essential methods void searchTitle(); void searchKeyword(); void searchStudio(); void searchMonthRelease(); struct MovieData fileOpen(); };
//Method to open the file and stores the values in the variables struct MovieData FilmDatabase::fileOpen() { struct MovieData m[100]; ifstream file; //open the file and prompt if an error occurs file.open("Films2015.txt");
//Display a relevant message if file //did not open if (file.fail()) { cout << " Can't open Films2015.txt "; }
//Read from the file for (int i = 0; i < 100; i++) { //If file is opened then read from it if (file.is_open()) { file >> m[i].rank; file >> m[i].FilmTitle; file >> m[i].Studio; file >> m[i].TotalGross; file >> m[i].TotalTheaters; file >> m[i].OpeningGross; file >> m[i].OpeningTheaters; file >> m[i].OpeningDate; return m[i]; } } //close the file file.close(); }
//Method to give the discription and working of the project char Movie::describe() { char choice; cout << "Hii in the following project, Movie names are " "given released in 2015. The movie names are " "sorted according to the Rank Report as well as " "title as user demand. In this project search " "technique is also applied. User can search " "by giving title name,studio name or by entering " "any keyword or by month. "; cout << " Press X to go to Main Menu : "; cin >> choice; return choice; }
//Method to display the choice of main menu char Menu:: getmenu() { char choice; cout << " Main Menu: "; cout << "D - Describe the Program : "; cout << "R - Reports : "; cout << "S - Search the Database : "; cout << "X - Exit the Program : "; cout << "Enter Selection -> "; cin >> choice; return choice; }
//Method to represent the options after clicking report char Menu::getReport() { char choice; cout << " REPORTS MENU: "; cout << "T - Order by Film Title report "; cout << "R - Order by Rank report "; cout << "X - Return to main menu "; cout << "Enter Selection -> "; cin >> choice; return choice; }
//Method shows switch case to show report choices void Menu::setReport(char ch) { Movie film; switch (ch) { case 'T': film.sortTitleReport(); break; case 'R': film.sortRankReport(); break; case 'X': break; default: cout << " Enter choice correctly : "; } }
//Method sorts the data according to ranks void Movie::sortRankReport() { struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } //Declare required variables int temp, i, j;
//For loops used for sorting for (i = 0; i <= 10; i++) { for (j = 0; j <= 10 - i; j++) { if (m[j].rank > m[j + 1].rank) { temp = m[j].rank; m[j].rank = m[j + 1].rank; m[j + 1].rank = temp; } } } cout << " Ranks after sorting: "; cout << "Rank\tMovieTitle\t\t\tStudio\t\tTotal Gross" "\tTotalTheaters\tOpening Gross\tOpening Theaters" "\tOpening Date" << " "; //Display after sorting for (int j = 0; j < 10; j++) { cout << m[j].rank << "\t"; cout << m[j].FilmTitle << "\t\t\t"; cout << m[j].Studio << "\t\t"; cout << m[j].TotalGross << "\t\t"; cout << m[j].TotalTheaters << "\t\t"; cout << m[j].OpeningGross << "\t" << "\t"; cout << m[j].OpeningTheaters << "\t\t"; cout << m[j].OpeningDate << " "; } }
//Method to display menu for search char Menu::getSearch() { char choice; cout << " Search MENU "; cout << "T - Search by Title "; cout << "K - Search by Keyword(s) "; cout << "S - Search by Studio "; cout << "M - Search by month of release "; cout << "X - Return to main menu "; cout << "Enter Selection -> "; cin >> choice; return choice; }
//Method for switch case to apply search operation void Menu::setSearch(char ch) { FilmDatabase data; switch (ch) { case 'T': data.searchTitle(); break; case 'K': data.searchKeyword(); break; case 'S': data.searchStudio(); break; case 'M': data.searchMonthRelease(); break; case 'X': break; default: cout << "Enter choice correctly : "; } }
//Method to search according to title void FilmDatabase::searchTitle() { struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } string title; cout << " Enter the movie Title to be searched: "; cin >> title; for (int i = 0; i < 100; i++) { if (title == m[i].FilmTitle) { cout << " Hi "<
//Method to search any keyword void FilmDatabase::searchKeyword() { struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } string title; cout << " Enter the movie keywords to be searched: "; cin >> title; for (int i = 0; i < 100; i++) { if (title == m[i].FilmTitle) { cout << " Hi " << title << " present in the top " "100 movie list. It is at the " << i << " rank "; } } }
//Method to search by studio names void FilmDatabase::searchStudio() { struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } string st; cout << " Enter the Studio name to be searched: "; cin >> st; for (int i = 0; i < 100; i++) { if (st == m[i].Studio) { cout << " Hi " << st << " present in the top 100" " movie list. It is at the " << i << " rank "; } } } void FilmDatabase::searchMonthRelease() { //struct MovieData film[100]; struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } string month; cout << " Enter the movie Title to be searched: "; cin >> month; for (int i = 0; i < 100; i++) { if (month == m[i].FilmTitle) { cout << " In " << month << " present in the list." " The movie released in this month is at " << i << " rank"; } } } //Method to sort the database by movie Titles void Movie::sortTitleReport() { struct MovieData m[100]; FilmDatabase film; for (int i = 0; i < 100; i++) { m[i] = film.fileOpen(); } int i, j; cout << "Movie Names in alphabetical order : "; for (i = 0; i<5; i++) { cout << m[i].FilmTitle << " "; } }
******************** Project1.cpp ********************
//Include required library files #include "stdafx.h" #include #include #include #include
//use namespace using namespace std;
//Start the main method int main() { Movie film; FilmDatabase data; Menu opt; struct MovieData m[100]; char menu, choice; //Starts do-while loop do { //Accepts the menu to display the choices to the user char ch = opt.getmenu();
//starts switch case switch (ch) { //case D to describe about the project case 'D': //method to describe about the working of project menu = film.describe(); break;
//Case R to describe about the Report case 'R': do { //method to display choices while displaying reports menu = opt.getReport();
//Method to start switch case opt.setReport(menu);
//Display message to continue do-while loop cout << " Do you want to continue (Y/N) : "; cin >> choice; } while (choice != 'N'); break;
//Case S to search in the movie database case 'S': do { //method to display choices while searching menu = opt.getSearch();
//Method to start switch case opt.setSearch(menu);
//Display message to continue do-while loop cout << " Do you want to continue (Y/N) : "; cin >> choice; } while (choice != 'N'); break; //case X to exit case 'X': exit(1); break; default: cout << "Enter choice correctly : "; } //Display message to continue do-while loop cout << " Do you want to continue (Y/N) : "; cin >> choice; } while (choice != 'N');
//Pause the system for a while system("pause");
//return 0 return 0; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started