Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

{ { { { { { { { { { { please c + + and create two differernt file hpp and cpp please and

{{{{{{{{{{{please c++ and create two differernt file hpp and cpp please and read carefully instruction everything}}}}}}}}}}}}}}}}}]
Task 1: The Creature class
UML
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.
Default-initializes all private members.
Default creature name: "NAMELESS".
Booleans are default-initialized to False.
Default enum value: UNKNOWN
Default Hitpoints and Level: 1.
*/
/**
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 non-alphabetic characters.
@param : The category of the creature (a Category enum) with default value UNKNOWN
@param : The creature's hitpoints (an integer), with default value 1 if not provided, or if the value provided is 0 or negative
@param : The creature's level (an integer), with default value 1 if not provided, or if the value provided is 0 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 non-alphabetic 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 >=0 : 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 >=0 : 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: [TRUE/FALSE]"
*/
display
Task2:UML Testing
2.1
-2.1
- Instantiate a creature with the default constructor
- Set its hitpoints to 10 using the appropriate setter function.
- Set its level to 5 using the appropriate setter functions
- Set its tame flag to True using the appropriate setter function.
- Print out the creature's information using the display() function:
Expected output:
NAMELESS
Category: UNKNOWN
Level: 5
Hitpoints: 10
Tame: TRUE
2.2
- Instantiate a creature with the parameterized constructor with the following creature details:
Name: Wormy
Category: MYSTICAL
Level: 2
Hitpoints: 3
- Set Wormy as Tame with the appropriate s
image text in transcribed

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

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books

Students also viewed these Databases questions