Create a simple C++ program with the 3 following classes. Use separate header and source files for each class. Make all of the class members public. Player name char[32] x, y floats sword - Sword * hit points - int max points - int Player() default constructor Player(char *) - constructor that sets the name heal (Flask *) - heals the player if their health is low and the flask passed in has charges. Do not over heal the player. display() prints the name, sword name and current hit points of the player. Sword name char[32] damage - int attack speed - float Sword() default Sword (char *) set the name Flask name char[32] charges (remaining) int health restored per charge - int Flask() In main create an instance of the Player class and 3 objects from the Sword class. All of these objects must be created on the heap by using the new keyword. Give the swords different names, damage and attack speed values. Equip the player with one of the swords by assigning one of the Sword objects to the player's Sword pointer. Set the player's hit points to half maximum value. Call display() on the player. Create an object from the Flask class. Use this on the player by calling the heal() function. From main() print out the remaining number of charges on the flask and the player's hit points to verify the flask healed the player. Free up the memory for all of the objects before closing up the program. Label all of the output clean and professional. You may add additional functions such as setName() if you wish. Use some comments throughout code to explain your work..

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Create a simple C++ program with the 3 following classes. Use separate header and source files for each class. Make all of the class members public.

Player

name char[32]

x, y floats

sword - Sword *

hit points - int

max points - int

Player() default constructor

Player(char *) - constructor that sets the name

heal (Flask *) - heals the player if their health is low and the flask passed in has charges. Do not over heal the player.

display() prints the name, sword name and current hit points of the player.

Sword

name char[32]

damage - int

attack speed - float

Sword() default

Sword (char *) set the name

Flask

name char[32]

charges (remaining) int

health restored per charge - int

Flask()

In main create an instance of the Player class and 3 objects from the Sword class. All of these objects must be created on the heap by using the new keyword. Give the swords different names, damage and attack speed values. Equip the player with one of the swords by assigning one of the Sword objects to the player's Sword pointer. Set the player's hit points to half maximum value.

Call display() on the player.

Create an object from the Flask class. Use this on the player by calling the heal() function. From main() print out the remaining number of charges on the flask and the player's hit points to verify the flask healed the player.

Free up the memory for all of the objects before closing up the program.

Label all of the output clean and professional. You may add additional functions such as setName() if you wish. Use some comments throughout code to explain your work..

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education