Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me with C++ lab. thank you In this lab youll be creating the Player class for Project 2. Your Player class will have

Please help me with C++ lab. thank you

In this lab youll be creating the Player class for Project 2.

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago