Question
C++ ONLY PLEASE. NEED SOME HELP MAKING THESE HEADER AND DRIVER FILES. THANKS IN ADVANCE. VideoGameLibrary class Attributes videoGamesArray a pointer to an array of
C++ ONLY PLEASE. NEED SOME HELP MAKING THESE HEADER AND DRIVER FILES. THANKS IN ADVANCE.
VideoGameLibrary class
Attributes
- videoGamesArray a pointer to an array of pointers. Each pointer in the array should be able to point to (hold the memory address of) an individual Video game object. [Hint: you will need TWO stars to define this attribute. ]
- maxGames this is the maximum number of video games the library can hold and is the size of the video gamesArray.
- numGames this is the current number of video games actually pointed to in the videoGamesArray.
Functions
Function name: resizeVideoGameArray
- Parameters: none
- Returns: none (void)
- Purpose: This function is called by addVideoGameToArray when the array size is not big enough to hold a new video game that needs to be added. The function makes the array twice as big as it currently is and then moves all the video game pointers to this new array.
Function name: VideoGameLibrary constructor
- Parameters: An integer containing the maximum size of the video game library
- Purpose: This function is automatically called when a VideoGameLibrary object is created and it creates a library of video games.
- Specification: The function will dynamically allocate an array of pointers to VideoGame objects based on the maximum size and will also set the current number of video games to zero.
Function name: ~VideoGameLibrary destructor
- Purpose: This function is automatically called when the VideoGame object is destroyed. This releases the dynamically created individual video games and then deletes the array.
- Prints a message VideoGameLibrary destructor: Released memory for each game in the video game array and the array itself.
Function name: addVideoGameToArray
- Parameters: none
- Returns: none (void)
- Purpose: This function should be called when you need to add a single video game to the video game library.
- Specifications: It should ask the user for the video game title (read in as c-string, then dynamically create a Text object), platform (read in as c-string, then dynamically create a Text object), video game year (integer), video game genre (read in as c-string, then dynamically create a Text object), video game age rating (read in as c-string, then dynamically create a Text object), and IGDB user rating (between 0 and 100). Then it should dynamically allocate a new VideoGame object, sending the video game data just acquired from the user as arguments to the VideoGame constructor. Then, this function should check to see if numGames is equal to maxGames. If it is equal, then call the resizeVideoGameArray function. Then, it should assign this new video game to the correct pointer in the videoGamesArray. Last, it should increment numGames.
Function name: displayVideoGames
- Parameters: none
- Returns: none (void)
- Purpose: This function should be called when the user wants to have all the video games in the library printed to the screen.
- Specifications: This function loops through the video gamesArray and calls each Video games printVideoGameDetails function.
Function name: displayVideoGameTitles
- Parameters: none
- Returns: none (void)
- Purpose: This function should be called when you want to print only the video game titles out of the video game library (when a user wants to remove a video game from library).
- Specifications: This function should loop through the video gamesArray, retrieve the Video games title by calling the Video games getVideoGameTitle function, and then printing out the title by calling the Texts displayText function.
Function name: loadVideoGamesFromFile
- Parameters: A pointer to a character (c-string or string literal argument) containing the filename
- Returns: none (void)
- Purpose: This function should be called when the user wants to read video game data from a file and add the video games to the video game library. The file must have data in the following order: title, platform, year, genre, age rating, IGDB user rating.
- Specifications: This function will use a loop to read the contents of the file until reaching the end of file. For each video game, it will read the title in with a c-string and then dynamically allocate a Text to hold the title. Then it will read in the video game platforms with a c-string and then dynamically allocate a Text to hold the platform. Then it will read in the video game year. Then it will read in the video game genre with a c-string and then dynamically allocate a Text to hold the genre. Then it will read in the video game age rating with a c-string and then dynamically allocate a Text to hold the rating. Then it will read in the user rating (between 0 & 100). Then, it will dynamically create a new VideoGame object, sending the video game data just acquired from the user as arguments to the Video game constructor. Then, this function should check to see if numGames is equal to maxGames. If it is equal, then call the resizeVideoGameArray function. Then, it should assign this new video game to the correct pointer in the video gamesArray. Then, it should increment numGames. Then, it should print the title of the video game and say was added to the video game library! This should happen for each video game read from the file. At the end of the function, it should print out how many video games were read from the file & added to the library.
[Note: The temporary c-string used to load in data should be able to hold a very large string 10000 characters]
Function name: removeVideoGameFromArray
- Parameters: none
- Returns: none (void)
- Purpose: This function should be called when the user wants to remove one single video game from the video game library. The video game to be removed must is identified by the user and then removed.
- Specifications: This function should first make sure that the number of video games is at least 1. if not, it should print that there must always be one video game in the library and the function should end. Then, the function should call the displayVideoGameTitles function to print all the video game titles. Then, ask the user to choose a video game to remove between 1 & numGames. Once the user identifies the video game, your program should print that the video game title has been successfully deleted. Then, release the dynamically allocated space for this video game and move all array elements in video gameArray back 1 starting with this deleted video games element. Last, decrement numGames.
Function name: saveToFile
- Parameters: A pointer to a character (c-string or string literal argument) containing the filename
- Returns: none (void)
- Purpose: This function should be called when the user wants to print all the video game data from the video game library to a file. The data is printed in the following order (one piece of data per line): title, platform, year, genre, age rating, IGDB user rating.
- Specifications: Use a loop to go through the video gameArray and call the Video games printVideoGameDetailsToFile function, sending the name of the file to be printed to. Then, close the file and print a confirmation that all video games have been printed to the filename.
videogame class
Attributes
- title a pointer to a Text object, which will hold the title of the video game
- platform a pointer to a Text object, which will hold the platforms that the video game is available on
- year an integer representing the year the video game was released
- genre a pointer to a Text object, which will hold the genre of the video game
- ageRating a pointer to a Text object, which will hold the age rating of the video game
- userRating a number between 0 and 100 representing the user rating from IGDB
Functions
Function name: VideoGame constructor
- Parameters:
- A pointer to a Text variable, containing the title of the video game
- A pointer to a Text variable, containing the platform(s) of the video game
- An integer containing the year the video game was released
- A pointer to a Text variable, containing the genre of the video game
- A pointer to a Text variable, containing the age rating of the video game
- A number containing the IGDB (user) rating of the video game (out of 100)
- Purpose: This function should be called when all video game information is known and it will create a new video game with this information.
- Specifications: initialize all attributes to the arguments sent to this function.
Function name: ~VideoGame destructor
- Purpose: This function is automatically called when a Video game object is destroyed. This function releases the dynamically allocated text arrays in the Video game.
- Specifications: Release the dynamically allocated space for the video gameTitle, video gameGenre, and video gameRating.
- Prints a message: VideoGame destructor: Released memory for title, platform, genre, & rating.
Function name: printVideoGameDetails
- Parameters: none
- Returns: none (void)
- Purpose: This function should be called when the user wants to print ALL the video game information to the screen.
- Specifications: Print the title, year, genre, rating & number of stars. Remember that in order to print the Text objects, you must call their displayText function.
Function name: printVideoGameDetailsToFile
- Parameters: a file stream object (sent by reference)
- Returns: none (void)
- Purpose: This function should be called when the user wants to print ALL the video game information to the file.
- Specifications: Print the title, year, genre, rating & number of stars to the filename that was sent to this function. In order to print the Text objects to the file, you must first retrieve the c-string attribute (calling the getText function) from this Text, and then you can print it to the file.
Function name: getVideoGameTitle (accessor function)
- Parameters: none
- Returns: a pointer to the Text object containing the video game title
Text class
Attributes
- textArray a pointer to a constant character array
- textLength an integer representing the number of characters stored in the textArray
Functions
Function Name: Text (constructor)
- Parameters: Send a pointer to a constant character array or a string literal to this function
- Purpose: called automatically when Text object is created, dynamically allocates a character array which contains the character array passed to the function.
- Specifications: dynamically allocate a new character string the size of the string passed to this function plus one (for the null terminator). Then, copy the text sent as an argument to this constructor to the new dynamically allocated c-string. Then, set the textArray attribute to this newly created c-string.
Function Name: ~Text (destructor)
- Purpose: release dynamically allocated memory for the c-string in the Text object
- Specifications: release the memory for the c-string pointed to by textArray
- Prints a message: Text destructor: Released memory for textArray.
Function Name: displayText
- Parameters: none
- Returns: none (void)
- Purpose: print the c-string (textArray) to the screen
Function Name: getText (accessor function)
- Parameters: none
- Returns: pointer to a constant character array
Function Name: getLength (accessor function)
- Parameters: none
- Returns: the length of the string
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