Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Do this in C++ PROGRAMMING Yassi is creating a health bar for a game. The problem is, she can't quite get it right. Help her!

Do this in C++ PROGRAMMING

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Yassi is creating a health bar for a game. The problem is, she can't quite get it right. Help her! She wants a player's health bar to be represented by 10 equal signs enclosed in square brackets, as in: Each equal sign represents 10% of the player's health. Yassi wants you to create a program that would simulate the stream of changes of a health bar after a series of damages and regeneration have been applied. The health bar always begins with 100% health. PROGRAM SPECIFICATION Program must have the following: 1. A void function called damage that takes two pass-by-reference arguments s and p, where s is the string representation of the health bar and p is an integer indicating the equivalent percentage value. It takes a third pass-by-value integer argument n indicating the amount of damage to be dealt. The function applies the damage and updates the health bar's string and percentage representations. 2. A void function called regenerate that takes two pass-by-reference arguments s and p, where s is the string representation of the health bar and p is an integer indicating the equivalent percentage value. It takes a third pass-by-value integer argument n indicating the amount of healing to be dealt. The function applies the healing and updates the health bar's string and percentage representations. 3. A void function called display that takes two pass-by-value arguments s and p, where s is the string representation of the health bar and p is the equivalent percentage value. The function displays the required output of the program. Input Format: Input starts with N, the number of test cases, followed by an arbitrary pairs of input in the format cn, where c could either be a plus sign (+) to indicate regeneration or a minus sign (-) to indicate damage, and n is an integer indicating the percentage of regeneration or damage. Output Format: For each input, display the health bar depicting its current state after the regeneration or damage has been applied followed by the percentage value. If regenerating results to a health bar more than 100%, represent it as % (e.g. [=========E] 100\%). If being damaged results to the health being equal to 0 or going below 0 , represent it as an empty health bar - 10 spaces enclosed in square brackets - with the string "DEAD" without the quotation marks (e.g. [ ] DEAD). If applying the regeneration or damage results to a value that is not a multiple of 10 , represent in the health bar its corresponding rounded down value but display the actual percentage (e.g. applying 5 to a 100% health bar results to 95%. The output should look like: [======== ] 95\%). The health bar and the corresponding percentage value/string "DEAD" should be separated by a single space. If the current health bar percentage is from 1 to 19 , health is depicted as one equal sign. Constraints: 1

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

Students also viewed these Databases questions