Question: Q 2 2 : Create a simple game that allows a user to create a monster and attack it . Use an Abstract Data Type

Q22: Create a simple game that allows a user to create a monster and attack it. Use an Abstract Data Type (ADT) to represent the monster. Your program should define a struct for the monster, an initialization function to create a new monster, and a function to attack the monster, which reduces its health. In your main program, create one monster instance, attack it once, and then print out the monster's current health.
Important Details
The monster struct should have a name (string) and health (integer).
Define a function createMonster that initializes a monster with a given name and full health (health =100).
Define a function attackMonster that takes a pointer to a monster and an attack power (integer), and reduces the monster's health by the attack power.
In your main program, prompt the user for the monster's name and the attack power. The monster's name could be multiple words separated by spaces.
After attacking the monster, print out the monster's name and its updated health.
If the monster's health drops below zero, set it to zero.
Your output should match the example outputs for each of the examples shown below.
You will author your solution in the provided ipynb file specific to this question. This file must be submitted to the correct location on the Google Form linked to this exam.
Q 2 2 : Create a simple game that allows a user

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!