Option A – 100 points maximum
Modify Assignment 8 (or 7, or 5) to:
It should not abort if the movie is not found.
You are free to create your own linked list solution, but it must incorporate templates, the node as a class, previous and next link pointers, and separate compilation. Note the key word ‘create’; please do not submit canned linked list solutions copied from
else
where.
Option B – 125 points maximum
Same as Option A, except
I Cant Seem to attach the Folder with it on the bottom for some reason. I pasted the homework assignment on the bottom.
Movie.cpp FILE
// Movies.cpp
#include “Movie.h” // include Movie class definition
#include “Movies.h” // include Movies class definition
#include
#include
using namespace std;
Movies::Movies(string fn){loadMovies(fn);}
void Movies::MakeTable(int S) {
for (int i = 0; i
movies[i] = NULL;
}
void Movies::loadMovies(string fn) {
MakeTable(SizeOfTable);
ifstream iS(fn);
string s;
int itemfound;
string SecTitle;
int SecHash;
getline(iS, s);
// skip heading
getline(iS, s);
while(!iS.eof()) {
itemfound = s.find_first_of(“\t”);
for (int i = 0; i < itemfound; i++)
SecTitle += s[i];
SecHash = runHash(SecTitle);
movies[SecHash] = new Movie(s);
SecTitle.clear();
getline(iS, s); }
iS.close();
}
const Movie * Movies::operator [] (int MM) const{
return movies[MM];
}
int Movies::runHash(string s) {
int hashing = 0;
for (int i = 0; i < s.length(); i++) {
hashing = ((31 * hashing) + s[i]);
}
int table = abs(hashing);
return table % SizeOfTable;
}
MovieInforApp.cpp FILE
// MovieInfoApp.cpp
#include “Movie.h” // include Movie class definition#include “Movies.h” // include Movies class definition
#include
#include
#include
void main() {
double ratioCalc = 0;
int Statement = 2;
Movies movies(“Box Office Mojo.txt”);
string movieCode;
while (Statement != 0) {
cout <<"===========================Welcome To a Movie Search Program=================" < cout << "Enter the Exact Movie Title that you would like to search" < cout <<"If you are done searching, Please Press Enter to Exit: " < getline(cin, movieCode); if(movieCode.length() > 0) { int hash = Movies::runHash(movieCode); Movie m = *movies[hash]; if(m.getTitle().length() > 0) { cout << m.toString()
<< "\n"; if(m.getWorldBoxOffice() > 0) { ratioCalc = ((float)m.getNonUSBoxOffice()/(float)m.getWorldBoxOffice())*100; cout << "The ratio of World Boxx Office to Non-Us Box Office is : " < << "%" << "\n\n\n";} else cout << "No ratio due to zero value for World Box Office\n\n\n";} else cout << ""; Statement = 8;} else { cout << "\n"; Statement = 0; } }} Movie.cpp FILE // Movie.cpp #include “Movie.h” // include Movie class definition#include #include using namespace std; Movie::Movie() { title = studio = “”; boxOffice[WORLD] = boxOffice[US] = boxOffice[NON_US] = rank[WORLD] = rank[US] = rank[NON_US] = releaseYear = 0; } Movie::Movie(string temp) { istringstream iS(temp); getline(iS, title, ‘\t’); getline(iS, studio, ‘\t’); iS >> releaseYear >> boxOffice[WORLD] >> boxOffice[US] >> boxOffice[NON_US] >> rank[WORLD] >> rank[US] >> rank[NON_US]; } string Movie::getTitle() {return title;} string Movie::getStudio() {return studio;} long long Movie::getWorldBoxOffice() {return boxOffice[WORLD];} long long Movie::getUSBoxOffice() {return boxOffice[US];} long long Movie::getNonUSBoxOffice() {return boxOffice[NON_US];} int Movie::getWorldRank() {return rank[WORLD];} int Movie::getUSRank() {return rank[US];} int Movie::getNonUSRank() {return rank[NON_US];} int Movie::getReleaseYear() {return releaseYear;} string Movie::toString() { ostringstream oS; oS << "\n\n Movie Information\n===================================================" << "\n Movie Title:\t" << title << " (" << releaseYear << ")" << "\n US Rank & Box Office:\t" << rank[US] << "\t$" << boxOffice[US] << "\nNon-US Rank & Box Office:\t" << rank[NON_US] << "\t$" << boxOffice[NON_US] << "\n World Rank & Box Office:\t" << rank[WORLD] << "\t$" << boxOffice[WORLD] << "\n";
return oS.str(); } Movies.h FILE // Movies.h #ifndef MOVIES_H #define MOVIES_H #include “Movie.h” #include class Movies { void MakeTable(int); static const int SizeOfTable = 23298; public: Movies(string); const Movie * operator [] (int) const; static int runHash(string s); private: void loadMovies(string); Movie * movies[SizeOfTable]; }; #endif Movie.h FILE // Movie.h #ifndef MOVIE_H #define MOVIE_H #include class Movie { string title, studio; long long boxOffice[3]; short rank[3], releaseYear; enum unit {WORLD, US, NON_US}; public: Movie(); Movie(string); string getTitle(); string getStudio(); string toString(); long long getWorldBoxOffice(); long long getUSBoxOffice(); long long getNonUSBoxOffice(); int getWorldRank(); int getUSRank(); int getNonUSRank(); int getReleaseYear(); };#endif I can email you the folder if you want. Please Let me know. Thanks