Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the RPG combat code, add the following functionality: Create a class called Potion Potions are used to heal a character The potion should have

Using the RPG combat code, add the following functionality:

Create a class called "Potion"

Potions are used to heal a character

The potion should have 2 private members: count and healingAmount

count holds the number of potions the player has available

healingAmount holds the amount of health recovered by the character

The potion constructor should allow the programmer to specify how many potions are available

The class should have a member function called "use"

the use function should be passed a character pointer or reference for the character being healed

the function should invoke the heal member function of the character using the potion

when the use function is called, the potion count should drop by 1

if the count value is 0 or lower, no healing should be performed

The class should have an accesser function called getCount() which returns the number of potions available

The combat code should now prompt the user whether they want to attack the creature or use a potion

if the user selects to use a potion, the npc/enemy character should still attack them

if the playerCharacter is slower than the npc/enemy character, they should be attacked before they get the chance to heal

you may collect user input to select attack or use potion however you want (collect a 1 or 2 from the user, etc.)

Add a name string member to the Character class

Add a string called "name" to the character class

Create an accesser function called getName() to the Character class

Allow the name to be set in the constructor for Character

(BONUS!) Add some flavor text to describe the premise for how the encounter began (some short story as to how the player ended up fighting the enemy character)

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

Data Management Databases And Organizations

Authors: Richard T. Watson

6th Edition

1943153035, 978-1943153039

Students also viewed these Databases questions