You are tasked with creating a simple game where players can choose to be either a Wizard or a Warrior and engage in a battle. A player's object will store their name, health points, and damage points. A Wizard object can use magic spells to deal damage, while a Warrior object can use their weapon to deal damage. Create a class named Player which has the following data members and member functions: • Data Members: name (string) • health (int) • damage (int) • Member Functions: • Player (string name, int health, int damage) - constructor that sets the data members to the given values • void attack (Player* opponent) - deals damage to the opponent based on the player's damage points • void takeDamage (int damage) - reduces the player's health by the given amount Create two subclasses of Player named Wizard and Warrior which inherit from player. Both Wizard and Warrior have an additional data member: • Data Members: mana (int) - available only for Wizard • weapon (string) - available only for Warrior Wizard has the following additional member function: • Member Functions: • void castSpell (Player* opponent) - deals damage to the opponent based on the player's mana points Warrior has the following additional member function: • Member Functions: • void swingWeapon (Player* opponent) - deals damage to the opponent based on the player's weapon's damage points In addition to the above, create getters and setters for all the data members (get Health, setHealth,... etc) Implement the member functions of the Player, Wizard, and Warrior classes. In the attack function of the player class, you should output a message describing attack a damage dealt to the opponent. In the takeDamage function, output a message describing how much damage the player took and their remaining health points. Create a main function named main-1-1.cpp, which creates one instance of a Wizard and one instance of a Warrior. The program should then simulate a battle between the two players. The battle should consist of the players taking turns attacking each other until one of them runs out of health points. After each attack, output a message describing the attack and the resulting damage dealt. At the end of the battle, output a message declaring the winner.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter10: Introduction To Inheritance
Section: Chapter Questions
Problem 1GZ
icon
Related questions
Question
Please code in c++ without using namespace std and please add comments in the code and Thank you :)
You are tasked with creating a simple game where players can choose to be either a Wizard or a
Warrior and engage in a battle. A player's object will store their name, health points, and damage
points. A Wizard object can use magic spells to deal damage, while a Warrior object can use their
weapon to deal damage.
Create a class named Player which has the following data members and member functions:
• Data Members:
o name (string)
o health (int)
• damage (int)
• Member Functions:
• Player (string name, int health, int damage) - constructor that sets the data
members to the given values
• void attack (Player* opponent) - deals damage to the opponent based on the player's
damage points
• void takeDamage (int damage) - reduces the player's health by the given amount
Create two subclasses of Player named Wizard and Warrior which inherit from Player. Both
Wizard and Warrior have an additional data member:
• Data Members:
omana (int) - available only for wizard
• weapon (string) - available only for Warrior
Wizard has the following additional member function:
• Member Functions:
void castSpell (Player* opponent) - deals damage to the opponent based on the
player's mana points
Warrior has the following additional member function:
• Member Functions:
• void swingWeapon (Player* opponent) - deals damage to the opponent based on the
player's weapon's damage points
In addition to the above, create getters and setters for all the data members (getHealth,
setHealth, ... etc)
Implement the member functions of the Player, Wizard, and Warrior classes. In the attack
function of the player class, you should output a message describing the attack and the damage
dealt to the opponent. In the takeDamage function, output a message describing how much
damage the player took and their remaining health points.
Create a main function named main-1-1.cpp, which creates one instance of a wizard and one
instance of a Warrior. The program should then simulate a battle between the two players. The
battle should consist of the players taking turns attacking each other until one of them runs out
of health points. After each attack, output a message describing the attack and the resulting
damage dealt. At the end of the battle, output a message declaring the winner.
Transcribed Image Text:You are tasked with creating a simple game where players can choose to be either a Wizard or a Warrior and engage in a battle. A player's object will store their name, health points, and damage points. A Wizard object can use magic spells to deal damage, while a Warrior object can use their weapon to deal damage. Create a class named Player which has the following data members and member functions: • Data Members: o name (string) o health (int) • damage (int) • Member Functions: • Player (string name, int health, int damage) - constructor that sets the data members to the given values • void attack (Player* opponent) - deals damage to the opponent based on the player's damage points • void takeDamage (int damage) - reduces the player's health by the given amount Create two subclasses of Player named Wizard and Warrior which inherit from Player. Both Wizard and Warrior have an additional data member: • Data Members: omana (int) - available only for wizard • weapon (string) - available only for Warrior Wizard has the following additional member function: • Member Functions: void castSpell (Player* opponent) - deals damage to the opponent based on the player's mana points Warrior has the following additional member function: • Member Functions: • void swingWeapon (Player* opponent) - deals damage to the opponent based on the player's weapon's damage points In addition to the above, create getters and setters for all the data members (getHealth, setHealth, ... etc) Implement the member functions of the Player, Wizard, and Warrior classes. In the attack function of the player class, you should output a message describing the attack and the damage dealt to the opponent. In the takeDamage function, output a message describing how much damage the player took and their remaining health points. Create a main function named main-1-1.cpp, which creates one instance of a wizard and one instance of a Warrior. The program should then simulate a battle between the two players. The battle should consist of the players taking turns attacking each other until one of them runs out of health points. After each attack, output a message describing the attack and the resulting damage dealt. At the end of the battle, output a message declaring the winner.
Expert Solution
steps

Step by step

Solved in 5 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage