Economic Health writing homework help
March 17, 2023
finance 2547192 2
March 17, 2023


Using Structs

The following program is going to revolve around creating and using the “Gladiator” struct, which will contain statistics about their performance in combat. Gladiators have some information:

Name – How they’re referenced to the player, provided by the player

Max Health – The amount of HP a gladiator will start each fight with

Current Health – The amount of HP a gladiator has left before they have lost the fight

Evasion – The % chance (0-100) that the gladiator will completely avoid incoming damage when defending

Critical – The % chance (0-100) that the gladiator will inflict twice the rolled damage when attacking the opponent (known as a crit)

Minimum Damage – The lowest amount of damage a gladiator can inflict with a successful attack

Damage Range – The most damage ABOVE Minimum Damage that the gladiator can inflict with a single, non-critical hit

E.X. Min 30, range 50 would result in damage between 30-80

See end of Chapter 8 slides

struct gladiator { … };

Write a program that performs the following:

  1. Tell the user that they are going to be hosting a fight! But first, we need to…
  2. Prompt the user for a name, which is then sent to the createGladiator(string) function
    1. createGladiator should return a gladiator, after randomly generating them according to the following rules:
      1. Max Health should be 150, 200, or 250
      2. Evasion and Crit should be two independent values chosen from 5, 10, or 15%
      3. Minimum Damage should be in the range 8-14, with Damage Range in the range 16-22
    2. After stats have been assigned in createGladiator, show the user the stats that were created or loaded using a showStats(gladiator) function, then ask the user if they wish to accept or reject their fighter before the function ends. If they reject the fighter, generate a new set of stats, with the same rules listed under 2.a, under the same name.
  3. Repeat step 2 once to obtain the second gladiator for your fight
  4. Once both fighters are obtained, they will take turns (starting with the first fighter) using the takeTurn(gladiator A, gladiator &B) function to attack each other. An attack by fighter A will reduce fighter B’s current health by the amount of attack damage. (Why is B a reference variable?) Crits and misses should both be reported. (A and B provided only for illustration purposes)
  5. Once one of the fighters have their health reduced to 0 or below, they have been defeated. Tell the user about who won the fight, along with any combat statistics you would like to track.
  6. Ask the user if they would like a rematch with the same fighters. If so, go to step 4.
  7. Ask the user if they would like to set up another fight with new fighters. If so, go to step 2

Extra Credit:

  • Include the option in createGladiator to load an existing gladiator from a file, as well as an option to save the victor of any given fight to a file. A hard-coded or user-input filename are both acceptable

Menu input should accept either a single lowercase char or an integer, prompts should tell user what to enter.


2 – Documentation, readability, format

2 – Filename and Header

1 – Output testing

2 – Proper program flow (conditions, loops, functions, etc)

3 – Proper use of structs


//Author: Eric May (your name)

//CPSC 121 Lab 7

//<MM/DD/YY> (Current Date)


<Last Name><First Initial>lab7.cpp

For example, my assignment would be named MayElab7.cpp


Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code “Newclient” for a 15% Discount!

NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.


The post Using-Structs appeared first on Top Premier Essays.


"Is this question part of your assignment? We Can Help!"

Nursing Coursework