Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in c + + Create a class called Player to represent a game player, with member variables for name, score, and level, and implement functions
in c Create a class called "Player" to represent a game player, with member variables for name, score, and level, and implement functions to set and retrieve these variables. In the game, the score reflects the player's performance and is incremented based on actions, while levels represent progression, introducing new challenges and complexity. Also, include Constructor and deconstructor.
Design a class called "Enemy" to represent enemy characters, including name, health, and damage attributes. Implement functions to set and retrieve these attributes. Additionally, include a boolean data member called "defeated" in the "Enemy" class, initially set to False. Also, include Constructor and deconstructor.
In the "Player" class, add a member function called "Attack" that takes an "Enemy" object as a parameter, reducing the enemy's health by the player's damage. Check if the enemy is already defeated before proceeding with the attack, displaying a message if they are. If the enemy's health becomes zero or less, set the "defeated" value to True.
Create a class called "Game" to manage game logic, with member variables for the player object and an array to store multiple enemy objects. Implement functions to initialize the game, display player information, perform game actions like attacking enemies, and track the number of defeated enemies.
Feel free to include additional logic for when the Enemy attacks the Player, if desired, to further enhance the project
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