Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

C++ homework

Modify Assignment 5 to:

  1. Replace the formatted output method (toString) with an overloaded output/insertion operator, and modify the driver to use the overloaded operator.
  2. Incorporate the capability to access movies by the movie number or by a search string, if this wasn’t part of your Assignment 5.
  3. 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 <string>

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 <string>

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 <iostream>

#include <iomanip>

#include <string>

#include <string.h>

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”

<< “n or a ^ to get the next movie (press Enter to exit): “;

getline(cin, movieCode);

if (movieCode.length() > 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 << m->toString() << “n”;

if(m->getWorldBoxOffice() > 0)

cout << setprecision(1) << fixed

<< “ntNon-US to World Ratio:t”

<< (m->getNonUSBoxOffice() * 100.0) / 

m->getWorldBoxOffice() << “%n” << endl;

else

cout << “No ratio due to zero World Box Officen”;

} else {

cout << “n Movie not found!nn” << endl;

mn = 0;

}

cout << “Please enter the movie search string,nentering a leading # to retrieve by movie number”

<< “n or a ^ to get the next movie (press Enter to exit): “;

getline(cin, movieCode);

} while (movieCode.length() > 0);

}

}

}

 

CPP FILE

 

// Movie.cpp

#include “Movie.h” // include Movie class definition

#include <sstream>

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 << “nn====================== Movie Informationn”

<< “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();

}

 

Movie::Movie(const Movie &mP) { // copy constructor

this->title = mP.title;

this->studio = mP.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 <fstream>

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<movieCnt &&

(myToLower(movies[ndx].getTitle()).find(mc)==

string::npos);ndx++);

mn = ndx<movieCnt?ndx+1:0;

return ndx<movieCnt?&movies[ndx]:nullptr;

}

}

 

const Movie * Movies::getMovie(int mc) const {

return (mc > 0 && mc <= movieCnt)?&movies[mc-1]:nullptr;

}

 

Movies::~Movies() {

delete[] movies;

movies = nullptr;

}

 

void Movies::loadMovies(string fn) {

ifstream iS(fn);

string s;

getline(iS, s); // skip heading

getline(iS, s);

movieCnt=0;

movies = new Movie[MAX_MOVIES];

while(!iS.eof()) {

movies[movieCnt++] = Movie(s);

getline(iS, s);

}

iS.close();

reSize();

}

 

void Movies::reSize() {

Movie * m = movies;

movies = new Movie[movieCnt];

for(int i=0;i<movieCnt;i++)

movies[i] = m[i];

delete[] m; // null assignment not needed; end of method

}

 

string Movies::myToLower(string s) const {

int n = s.length();

string t(s);

for(int i=0;i<n;i++)

t[i] = tolower(s[i]);

return t;

}

 

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW


Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.