Summary task: C++ language; practice combining tools(functions, arrays, different kind of loops) to solve somewhat complex problem.
Description
A Valiant Hero is about to go on a quest to defeat a Vile Monster. However, the Hero is also quite clever and wants to be prepared for the battle ahead. For this question, you will write a program that will simulate the results of the upcoming battle so as to help the hero make the proper preparations.
Part 1
First, you will write a a function with the following header:
int battle(int HeroHealth, int HeroStrength, int HeroAccuracy, int MonsterHealth, int MonsterStrength, int MonsterAccuracy, int HeroSpeed, int MonsterSpeed)
Hero and Monster Health: Integer from (1 to 100). Indicates how much damage the hero and monster can take before being defeated.
Hero and Monster Strength: Integer from (1 to 100). Indicates how much damage a character inflicts when they successfully hit their opponent
Hero and Monster Accuracy: Integer from (1 to 100). Indicates how likely a character is to successfully hit their opponent
Hero and Monster Speed: Integer from (1 to 100). Indicates which character will strike first in the battle.
The function itself simulates one battle between the Hero and the Monster. Your function should return the Hero's remaining health after the battle; if the Hero loses the battle, then the Hero's health will be 0.
The rules for the battle are as follows. The hero and the monster will take turns attacking each other until one or the other is dead (hint: this means you will need to keep track of whose turn it is to attack!). The character with the higher speed takes the first turn; if tied, the hero goes first. Whenever one of the combatants attacks, you will determine the outcome of an attack by the following method:
Generate a random number between 1 and 100 (see Technical notes below). Call this the "attack".
If the attack is less than or equal to the attacker's Accuracy, the attack is a hit. For example, if the attacker's Accuracy is 60, and the attack is 42, the attack is a hit. In the case of a hit, the damage is equal to the attacker's Strength, so subtract the attacker's Strength from the target's Health.
If the attack is not a hit, then there is no damage, and the target's Health does not change.
***For this function, you must use a do-while loop. No other kind of loop is allowed!!***
The battle is over as soon as either the hero or the monster is reduced to zero or less Health. Once the battle is over, your function should return the Hero's remaining health.
Technical notes
As per Assignment 5, you need the following infrastructure to use random numbers in your program.
You need the following includes at the top:
#include <cstdlib>
#include <time.h>
The very first line of your main() function should be:
srand(time(NULL));
Finally, the following line of code will generate a random number from 1 to 100 and store it in a variable called number.
int number = (rand() % 100) + 1;
Part 2
Now that you are done your battle() function, you will write code in your main() function to use it to answer a bunch of what-if type questions, such as "Which weapon is best against which monster?" and "Can the hero expect to survive a battle against any of the monsters?" We'll answer the questions using a technique called simulation: we'll set up the battle once, then play the battle 1000 times, collecting data each time. Then we'll use simple summaries to draw conclusions. We'll need two steps.
Part 2 Step 1: Your program will allow the user to customize the basic attributes for the Hero and the Monster. Your program should do this as follows:
First, set the Hero's base Health to 50.
Second, ask the user (using cin) for the Hero's weapon: The user should type in one of sword, axe or dagger.
A sword gives the hero 8 Strength and 70 Accuracy and 15 Speed.
An axe gives the hero 10 Strength and 50 Accuracy and 10 Speed.
A dagger gives the hero 4 Strength and 95 Accuracy and 20 Speed.
Third, ask the user (using cin) for the Hero's defense item: the user should type one of platemail, shield or headband.
Platemail gives the hero +30 Health (i.e., an additional 30 health added to the base health) and -5 Speed (it's heavy!)
A shield reduces the Monster's strength by 2 (e.g. it makes the Hero take 2 less damage from each hit)
A headband reduces the Monster's accuracy by 10 (e.g. the Hero can dodge the Monster's attack, because s/he looks so cool!) and gives the hero +5 Speed
Finally, ask the user (using cin) for the type of Monster to fight: the user should type one of massive, sneaky or fast.
Massive monsters have 100 Health, 40 Strength, 15 Accuracy and 6 Speed.
Sneaky monsters have 10 Health, 30 Strength, 75 Accuracy and 12 Speed.
Fast monsters have 75 Health, 5 Strength, 99 Accuracy and 24 Speed.
Make sure you have this working before going on. You can test your work so far with a single battle according to the options chosen by the user.
Part 2 Step 2: We'll want to repeat the simulation 1000 times. Each call to battle() returns the hero's health, so you can tell if the hero won or not (zero health is a loss). To store the data, you should declare an array of integers of size 1000 (one element for each battle simulation).
Next, write a for-loop that will simulate 1000 battles between the Hero and the Monster, all of which use the same set-up (hero weapon, hero defense item and monster type) that the user specified above. After each battle simulation, record the Hero's remaining Health in your array.
Once the 1000 simulations are done, you should use the results that you stored in your array to display to the console (using cout) the following values. Again, you can only use for-loops in your main() function to do this.
How often the Hero won the battle
The average Health the Hero had remaining whenever the Hero won the battle. So when the hero loses, you should not update the average remaining Health.
A typical run of your finished program might look like this:
Welcome, Hero!
What is your weapon (sword, axe, dagger)? sword
What is your defense item (platemail, shield, headband)? headband
What type is the Monster (massive, sneaky, fast)? massive
********
The Hero defeated the Monster in ??? out of 1000 battles.
On average, the Hero had ??? Health left after winning.
(the ??? are there because I am a big meanie and I am not telling you what kind of results to be expecting...)
Check that your output makes sense! An error in your program may result in data that only looks wrong if you look carefully.
Results
Now that your program is working, you can use it to answer some questions to help the Hero prepare for battle. You will submit a Results file that answers the following questions:
Against Massive Monsters, what is the best equipment set for the Hero? How often does the Hero win with that set? What is the Hero's average remaining Health with that set?
Against Sneaky Monsters, what is the best equipment set for the Hero? How often does the Hero win with that set? What is the Hero's average remaining Health with that set?
Against Fast Monsters, what is the best equipment set for the Hero? How often does the Hero win with that set? What is the Hero's average remaining Health with that set?









Summary task: C++ language; practice combining tools(functions, arrays, different kind of loops) to solve somewhat complex...
HIGHEST SUBMISSION Vlew All Submissions Submission 17 Submitted on 6/10/2019 12 35 PM by Jenna Saleh DESCRIPTION Objectives To write a classes based on sets of specifications To write a main class to be used in a multi-class Java program To use inheritance to extend a class (optional, EC) To override methods in subclasses (optional, EC) Groups You may work with a partner on this assignment. A header comment (In every Java file) should include authors (group members) and collaborators...
Need this in C
The starter code is long, if you know how to do it in other way
please do.
Do the best you can please.
Here's
the starter code:
//
-----------------------------------------------------------------------
// monsterdb.c
//
-----------------------------------------------------------------------
#include
#include
#include
//
-----------------------------------------------------------------------
// Some defines
#define NAME_MAX 64
#define BUFFER_MAX 256
//
-----------------------------------------------------------------------
// Structs
typedef struct
{
char name[NAME_MAX];
int hp;
int attackPower;
int armor;
} Character;
typedef struct
{
int size;
Character *list;
} CharacterContainer;
//
-----------------------------------------------------------------------
//...
Risk management in Information Security today Everyday information security professionals are bombarded with marketing messages around risk and threat management, fostering an environment in which objectives seem clear: manage risk, manage threat, stop attacks, identify attackers. These objectives aren't wrong, but they are fundamentally misleading.In this session we'll examine the state of the information security industry in order to understand how the current climate fails to address the true needs of the business. We'll use those lessons as a foundation...