Modify the code below to create a "Favorite Video Game List" program that is contained in three files: Game.h Game.cpp Game_List.cpp You will need do to these things as you modify the code and put it...



Modify the code below to create a "Favorite Video Game List" program that is contained in three files:




  • Game.h


  • Game.cpp


  • Game_List.cpp




You will need do to these things as you modify the code and put it into the three files:




  • Create a class called "Game" (instead of "Movie") that contains 3 private variables ("title", "year", and "rating")

    • The "year" is when the game first came out.

    • The "rating" should be from 1 to 5 (5 being the best).

    • Add the appropriate member functions of the class (setters and getters).

    • Continue to use the get_title_upper() function as part of the class, Game, and in the output within the main file, Game_List.cpp.









    • Add the Default Constructor for the class with the member functions of the class.


    • Ignore the Destructor codefor now. It's there to show you where it ends up in future code.






  • Don't forget to add the include guard to the .h file







  • Use the scope resolution operator correctly for each file.


  • Don't use the "using namespace std;" for the main file, Game_List.cpp.

    • Instead, use the "using" declaration

      • using std::cout;

      • using std::endl;

      • using std::string;

      • etc.



    • See the example file Movie.cpp below if you are confused.








/*


    Interface File: Movie.h



    Declaration of Movie Class


(Variables - "Data Members" or "Attributes"


AND Functions - "Member Functions" or "Methods")


*/



#ifndef MOVIE_H     // Include Guard or Header Guard -If already defined ignore rest of code


#define MOVIE_H     // Otherwise, define MOVIE_H



#include



                    // Note: Not "using namespace std;" or even "using std::string"



class Movie


{


private:


    std::string title = "";    // Explict scope used  -->  std::string


    int year = 0;


public:


    Movie(std::string title = "", int year = 1888);     // Declaring a Default Constructor


    // ~Movie();                                     // A Deconstructor used for freeing up resources



    void set_title(std::string title_param);


    std::string get_title() const;           // "const" safeguards class variable changes within function


    std::string get_title_upper() const;


    void set_year(int year_param);


    int get_year() const;



};           // NOTICE: Class declaration ends with semicolon!




#endif   // MOVIE_H




/*


    Implementation file: Movie.cpp



Implements the functions declared in the interface file (Movie.h)



*/



#include


#include "Movie.h"




// This code only needs "using" to enable the use of "string". Other programs would have a longer list here!



using std::string;




Movie::Movie(string title, int year)   // Constructor definition


{


    set_title(title);


    set_year(year);


}



/* ~Movie::Movie()                    // Deconstructor definition


{


    CODE FOR FREEING UP RESOURCES


}


*/



void Movie::set_title(string title_param)


{


    title = title_param;


}



string Movie::get_title() const


{


    return title;


}



string Movie::get_title_upper() const


{


    string title_upper;


    for (char c : title) {


        title_upper.push_back(toupper(c));


    }


    return title_upper;


}



void Movie::set_year(int year_param)


{


    year = year_param;


}



int Movie::get_year() const


{


    return year;


}





/*


    Main file: Movie_List.cpp



    Utilizes Class Movie



*/



#include


#include


#include


#include


#include "Movie.h"




// You need to replace "using namespace std;"  with "using" declarations (see Movie.cpp as an example)



using namespace std;    // Replace this with "using std::cout", etc.




int main()


{


    cout < "the="" movie="" list="">


< "enter="" a="">



    // get vector of Movie objects


    vector movies;


    char another = 'y';


    while (tolower(another) == 'y')


    {


        Movie movie;      // movie is initialized with the Default Constructor values



        string title;


        cout < "title:="">


        getline(cin, title);


        movie.set_title(title);



        int year;


        cout < "year:="">


        cin >> year;


        movie.set_year(year);



        movies.push_back(movie);



        cout < "\nenter="" another="" movie?="" (y/n):="">


        cin >> another;


        cin.ignore();


        cout <>


    }



    // display the movies


    const int w = 10;


    cout <>


< setw(w="" *="" 3)=""><>


< setw(w)="">< "year"=""><>



    for (Movie movie : movies)


    {


        cout < setw(w="" *="" 3)=""><>


 < setw(w)="">< movie.get_year()=""><>


    }



    cout <>



    // Output with titles in ALL CAPS


    for (Movie movie : movies)


    {


        cout < setw(w="" *="" 3)=""><>


 < setw(w)="">< movie.get_year()=""><>



Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here