Question: Can you guys help me with this homework? C++ --------------------------- Your Player class will have the following member variables ( attributes ): name of the

Can you guys help me with this homework? C++

---------------------------

Your Player class will have the following member variables (attributes):

name of the player (string)

age of the player (integer)

Your Player class should have the following member functions (methods):

Constructors: have at least one default constructor.

Accessors: write one get method for each member variable

Mutators: write one set method for each member variable.

Functionality Methods: void print()displays the players information in whatever format you choose.

Create three source code files (player.h, player.cpp, and main.cpp). In player.h, place the definition for your class. In player.cpp, place the code for the methods of your class. In main.cpp, you should have a main function that:

Creates an array of 20 player objects, which Ill name players.

Asks the user for an array index then calls a function called createNewPlayer that takes the players array and the array index entered by the user. You should write the createNewPlayer function so that it asks the user for the attributes of a player object (name and age), then stores these into the correct location in the array, as indicated by index, using the set methods of the class.

Asks the user for a players name then calls a function called modifyPlayer that takes the players array and the name entered by the user. You should write the modifyPlayer function so that it searches through the array looking for a player whose name matches the name entered by the user. If the Player is in the array, then ask the user what attribute should be modified (name or age), get the new value, and then set the Player's attribute to this new value. If the player does not exist, give an error message.

Calls a function called printPlayers that takes two parameters, the players array and total (which holds the total number of players entered by the user). For the purposes of this lab activity, when testing the function just pass 20 for total even though the user will not have entered this many players. Write the printPlayers function so that it calls the print method for each of the players in the array from index 0 to total minus 1.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!