Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ D&D program properly implements both header and source files for your functions. All input should be fully validated You should have two header and

C++ D&D

program properly implements both header and source files for your functions. All input should be fully validated image text in transcribed

image text in transcribed

image text in transcribed

You should have two header and source files, one for the Person class and its methods and the Player class and its methods. Note that Player header needs to include Person header. You should also have separate header and source files for getInteger since it is called both in main to get the number of characters and in createCharacter to get an age. Person Class The Person class should include three private variables, string firstName, lastName and int age. It should have a default constructor that sets both names to "" and age to 0. It should have an overloaded constructor that has parameters to set all values. All constructors should use initialization lists. There should be a destructor that does nothing. All variables should have setters and getters. All getters should be constant. All setters and getters should be inline functions (defined in class). The source file for Person will be empty. Player Class The Player class is an abstract class. It includes an instance of a Person, which should be created dynamically and deleted when Player goes away, this is an example of class composition. Constructor - default constructor creates a default Person, overloaded constructor has parameters firstName, lastName, and age and creates Person using those values. Destructor - deletes the Person. getPlayerName - returns a single string that is firstName, space, lastName getPlayerAge - returns the age getClassName, getAction - pure virtual functions with return type string. . . . Character Classes The four different character classes all inherit from Player. Each has an overloaded constructor with parameters firstName, lastName, and age that is used to initialize Player. They also all override the getClassName and getAction methods with the following information. Class Ranger - "shoots arrows" Class Wizard - "casts fireballs Class Rogue - "picks pockets" Class Priest - "heals Helper Functions getInteger o used to get an input value o input parameters are min and max value o get and validates an integer between min and max o return the value o createPlayer o used to dynamically create a new character class get both names and age, age validated as between 5 and 90. get character class, validated to be in one of the above classes use names and age to dynamically create proper character using a Player pointer o return the Player pointer O display Players used to display array of Players o for each player display the full name, age, and class o no return values Main functionality Your main program should ask the user how many players are in the game. It should use getInteger to enter a value between 5 and 10 and create a dynamic array of Player pointers. It should have a for loop that calls createPlayer and fills the array with the returned Player objects. Finally, it should call displayPlayers to list each player's full name, age, class, and action. Example Output sue jones aged 25 playing a Priest heals bob smith aged 30 playing a Rogue picks pocket mary smith aged 35 playing a Wizard casts fireballs joe jones aged 27 playing a Ranger shoots arrows barb player aged 32 playing a Wizard casts fireballs fred flintstone aged 45 playing a Rogue picks pocket martha flintstone aged 46 playing a Priest heals You should have two header and source files, one for the Person class and its methods and the Player class and its methods. Note that Player header needs to include Person header. You should also have separate header and source files for getInteger since it is called both in main to get the number of characters and in createCharacter to get an age. Person Class The Person class should include three private variables, string firstName, lastName and int age. It should have a default constructor that sets both names to "" and age to 0. It should have an overloaded constructor that has parameters to set all values. All constructors should use initialization lists. There should be a destructor that does nothing. All variables should have setters and getters. All getters should be constant. All setters and getters should be inline functions (defined in class). The source file for Person will be empty. Player Class The Player class is an abstract class. It includes an instance of a Person, which should be created dynamically and deleted when Player goes away, this is an example of class composition. Constructor - default constructor creates a default Person, overloaded constructor has parameters firstName, lastName, and age and creates Person using those values. Destructor - deletes the Person. getPlayerName - returns a single string that is firstName, space, lastName getPlayerAge - returns the age getClassName, getAction - pure virtual functions with return type string. . . . Character Classes The four different character classes all inherit from Player. Each has an overloaded constructor with parameters firstName, lastName, and age that is used to initialize Player. They also all override the getClassName and getAction methods with the following information. Class Ranger - "shoots arrows" Class Wizard - "casts fireballs Class Rogue - "picks pockets" Class Priest - "heals Helper Functions getInteger o used to get an input value o input parameters are min and max value o get and validates an integer between min and max o return the value o createPlayer o used to dynamically create a new character class get both names and age, age validated as between 5 and 90. get character class, validated to be in one of the above classes use names and age to dynamically create proper character using a Player pointer o return the Player pointer O display Players used to display array of Players o for each player display the full name, age, and class o no return values Main functionality Your main program should ask the user how many players are in the game. It should use getInteger to enter a value between 5 and 10 and create a dynamic array of Player pointers. It should have a for loop that calls createPlayer and fills the array with the returned Player objects. Finally, it should call displayPlayers to list each player's full name, age, class, and action. Example Output sue jones aged 25 playing a Priest heals bob smith aged 30 playing a Rogue picks pocket mary smith aged 35 playing a Wizard casts fireballs joe jones aged 27 playing a Ranger shoots arrows barb player aged 32 playing a Wizard casts fireballs fred flintstone aged 45 playing a Rogue picks pocket martha flintstone aged 46 playing a Priest heals

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions