Question: CSCE 2 0 0 4 : Programming Foundations 1 Homework 7 Due: 5 / 0 2 / 2 4 Problem Statement So , you ve

CSCE 2004: Programming Foundations 1
Homework 7
Due: 5/02/24
Problem Statement
So, youve mastered dice rolling, now its time to start playing! The purpose of this assignment is
to create a basic Character class for Dungeons & Dragons. The Character class will store various
information about a character, including their name, character class, hit points, and more! Once
the Character class is working, you will implement a character creator in your main() function
that will let the user create multiple characters and save each character into its own .txt file.
Required Methods
You have been supplied with the Character.h file. Here are the descriptions of the functions that
should be implemented in Character.cpp. There are comments in your starter code that also
help explain more, including which parameters are pass-by-reference or pass-by-value.
1. Default Constructor
a. Parameters: none
This function initializes all the instance variables for the Character object to their
starter values. This includes generating random stats for the character. Because we
do not know the class yet, we cannot generate hit points yet.
2. Parameterized Constructor
a. Parameters: two strings (the name and class), an integer (the level), and a
boolean
This function initializes all the instance variables to the respective parameter. It then
generates random stats and then the characters hit points.
3. Copy Constructor
a. Parameters: another Character object
This function creates a copy of the Character object that is passed in.
4. Destructor (provided!)
a. Parameters: none
This function reallocates memory upon the end of the program.
5. Getters
a. Parameters: none, except for getStat() which will take the index of the stat
b. Returns: the appropriate type of the instance variable being retrieved
6. Setters
a. Parameters: the appropriate type of the instance variable being set
b. Returns: none
7. print (provided!)
a. Parameters: none
b. Returns: none
This function prints out all the information about a Character.
8. saveCharacterSheet
a. Parameters: none
b. Returns: true if a sheet was successfully made, false otherwise
This function will create a .txt file that stores all of the information about a Character.
The file should be the characters name with the .txt extension.
9. generateSpellList
a. Parameters: an array of all possible spells and the size of said array
b. Returns: none
This function will randomly assign 10 spells from the array of all possible spells to the
characters spells. There should be no repeat spells on the characters list.
10. generateRandomStats
a. Parameters: none
b. Returns: none
This function will randomly generate and save a number for each of the characters
stats between 8 and 20.
11. generateHitPoints (provided!)
a. Parameters: none
b. Returns: none
This function will generate the characters hit points based off their class, level, and
constitution score.
12. reset
a. Parameters: none
b. Returns: none
This function reset all the instance variables for the Character object to their starter
values. This includes generating new, random stats and new hit points for the
character.
13. readInSpells (to be implemented in hw7.cpp)
a. Parameters: the name of the file containing the complete list of spells and an
array to store those spells in
b. Returns: true if the spells are successfully stored, false otherwise
This function will read each line from a file containing the complete list of spells and
store each spell in the array.

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 Programming Questions!