Details of this Paper

C++ homework




Modify Assignment 5 to;Replace the formatted output method (toString) with an overloaded output/insertion operator, and modify the driver to use the overloaded operator.;Incorporate the capability to access movies by the movie number or by a search string, if this wasn't part of your Assignment 5.;Replace the getMovie(int) [or your solution equivalent] with an overloaded subscript operator ([ ]), which takes an integer and returns a Movie (or Movie reference).;Account for an invalid movie number.;HEADER FILE;// Movie.h;#ifndef MOVIE_H;#define MOVIE_H;#include;using namespace std;class Movie;// data is private by default;string title, studio;long long boxOffice[3], // World, US, non-US;short rank[3], releaseYear, // World, US, non-US;enum unit {WORLD, US, NON_US};public;Movie();Movie(string);string getTitle() const;string getStudio() const;long long getWorldBoxOffice() const;long long getUSBoxOffice() const;long long getNonUSBoxOffice() const;int getWorldRank() const;int getUSRank() const;int getNonUSRank() const;int getReleaseYear() const;string toString() const;private;Movie(const Movie &), // private copy constructor blocks invocation;#endif;HEADER FILE;// Movies.h;#ifndef MOVIES_H;#define MOVIES_H;#include "Movie.h" // include Movie class definition;#include;using namespace std;class Movies;// data is private by default;static const int MAX_MOVIES = 1000;Movie *movies;short movieCnt;public;Movies(string);int getMovieCount() const;const Movie * getMovie(string, int&&) const;const Movie * getMovie(int) const;~Movies();private;void loadMovies(string);string myToLower(string) const;void reSize();#endif;CPP FILE;// MovieInfoApp.cpp;#include "Movie.h" // include Movie class definition;#include "Movies.h" // include Movies class definition;#include;#include;#include;#include;using namespace std;void main();Movies movies("Box Office Mojo.txt");if(movies.getMovieCount() > 0);string movieCode;cout << "Please enter the movie search string,\nentering a leading # to retrieve by movie number;< 0);int mn = 0;const Movie * m;do;if(movieCode[0] != '#' && movieCode[0] != '^');m = movies.getMovie(movieCode, mn);else if(movieCode[0] == '#'){ // get by number;mn = stoi(movieCode.substr(1));m = movies.getMovie(mn);else if(movieCode[0] == '^') // get next movie;m = movies.getMovie(++mn);if(m != nullptr);cout < toString() < getWorldBoxOffice() > 0);cout << setprecision(1) << fixed;<< "\n\tNon-US to World Ratio:\t;getWorldBoxOffice() << "%\n" << endl;else;cout << "No ratio due to zero World Box Office\n;else;cout << "\n Movie not found!\n\n" << endl;mn = 0;cout << "Please enter the movie search string,\nentering a leading # to retrieve by movie number;< 0);CPP FILE;// Movie.cpp;#include "Movie.h" // include Movie class definition;#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() const {return title,};string Movie::getStudio() const {return studio,};long long Movie::getUSBoxOffice() const {return boxOffice[US],};long long Movie::getNonUSBoxOffice() const {return boxOffice[NON_US],};long long Movie::getWorldBoxOffice() const {return boxOffice[WORLD],};int Movie::getUSRank() const {return rank[US],};int Movie::getNonUSRank() const {return rank[NON_US],};int Movie::getWorldRank() const {return rank[WORLD],};int Movie::getReleaseYear() const {return releaseYear,};string Movie::toString() const;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];< title = mP.title;this->studio =;this->releaseYear = mP.releaseYear;this->rank[US] = mP.rank[US];this->rank[NON_US] = mP.rank[NON_US];this->rank[WORLD] = mP.rank[WORLD];this->boxOffice[US] = mP.boxOffice[US];this->boxOffice[NON_US] = mP.boxOffice[NON_US];this->boxOffice[WORLD] = mP.boxOffice[WORLD];CPP FILE;// Movies.cpp;#include "Movie.h" // include Movie class definition;#include "Movies.h" // include Movies class definition;#include;using namespace std;Movies::Movies(string fn){loadMovies(fn),};int Movies::getMovieCount() const {return movieCnt,};const Movie * Movies::getMovie(string mc, int& mn) const;if(mc.length()==0);return nullptr, // not found;else;mc = myToLower(mc);int ndx=0;for(,ndx


Paper#72667 | Written in 18-Jul-2015

Price : $22