Answered step by step
Verified Expert Solution
Question
1 Approved Answer
please use c + + with hpp and cpp file Every Creature has a Name, Category, Hitpoints, Level, and a boolean if the creature is
please use c with hpp and cpp file Every Creature has a Name, Category, Hitpoints, Level, and a boolean if the creature is Tame.
The Creature class must define the following type INSIDE the class definition:
An enum named Category with values UNKNOWN UNDEAD, MYSTICAL, ALIEN
The Creature class must have the following private member variables:
private:
The name of the creature a string in UPPERCASE
The category of the creature an enum
The creature's hitpoints an integer
The creature's level an integer
A boolean flag indicating whether the creature is tame
The Creature class must have the following public member functions:
Constructors
Default constructor.
Defaultinitializes all private members.
Default creature name: "NAMELESS".
Booleans are defaultinitialized to False.
Default enum value: UNKNOWN
Default Hitpoints and Level:
Parameterized constructor.
@param : A reference to the name of the creature a string Set the creature's name to NAMELESS if the provided string contains nonalphabetic characters.
@param : The category of the creature a Category enum with default value UNKNOWN
@param : The creature's hitpoints an integer with default value if not provided, or if the value provided is or negative
@param : The creature's level an integer with default value if not provided, or if the value provided is or negative
@param : A flag indicating whether the creature is tame, with default value False
@post : The private members are set to the values of the corresponding parameters. The name is converted to UPPERCASE if it consists of alphabetical characters only, otherwise it is set to NAMELESS.
Hint: Notice the default argument in the parameterized constructor.
Accessors get and Mutators set
@param : the name of the Creature, a reference to string
@post : sets the Creature's name to the value of the parameter in UPPERCASE.
convert any lowercase character to uppercase
Only alphabetical characters are allowed.
: If the input contains nonalphabetic characters, do nothing.
@return : true if the name was set, false otherwise
setName
@return : the name of the Creature
getName
@param : a reference to Category, the category of the Creature an enum
@post : sets the Creature's category to the value of the parameter
: If the given category was invalid, set category to UNKNOWN.
setCategory
@return : the category of the Creature in string form
getCategory
@param : a reference to integer that represents the creature's hitpoints
@pre : hitpoints : Characters cannot have negative hitpoints
do nothing for invalid input
@post : sets the hitpoints private member to the value of the parameter
@return : true if the hitpoints were set, false otherwise
setHitpoints
@return : the value stored in hitpoints
getHitpoints
@param : a reference to integer level
@pre : level : Characters cannot have a negative level
@post : sets the level private member to the value of the parameter
do nothing for invalid input
@return : true if the level was set, false otherwise
setLevel
@return : the value stored in level
getLevel
@param : a reference to boolean value
@post : sets the tame flag to the value of the parameter
setTame
@return true if the creature is tame, false otherwise
Note: this is an accessor function and must follow the same convention as all accessor functions even if it is not called getTame
isTame
@post : displays Creature data in the form:
NAME
Category: CATEGORY
Level: LEVEL
Hitpoints: Hitpoints
Tame: TRUEFALSE
display
Task: Testing
To help you establish a good practice for testing, we will make the testing of your code part of the assignment. After the first few projects, this will simply be your regular development practice thoroughly test every function you implement before moving to the next function and we will no longer request that you submit a test file.
If you want to submit to Gradescope before completing this test file, you can simply submit an empty main function, or a partially implemented function. Comment out any untested or buggy code.
Submit a file called test.cpp tat includes only a main function that does the following:
Instantiate a creature with the default constructor
Set its hitpoints to using the appropriate setter function.
Set its level to using the appropriate setter functions
Set
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