The question is below. I am also attaching 2 pictures. This is not graded and please make sure to read what I asked. I can upload a doc of the question so I have copy pasted the question.        PLEASE make sure the c++ code works in visual studios                Scenario: Two armies go to war. However there is a single bridge that connects both armies. Only one soldier from each army can fit on the bridge at a time.   Objective: Simulate a simple battle between the two armies.   Restrictions:   The soldiers in each army are created with random stats   The soldiers fight one at a time   Process:   Step 1: Create a Soldier class as outlined below.   Function “takeDamage” takes an integer and reduce the soldiers hp by that amount.   Step 2 : create a WarData class   WarData() -> creates the two armies as linked lists (using the STL)   “generateArmy1 “ creates and adds soldiers to army1 (linked list)    num represents the number of soldiers to be created   maxSoldierHealth represents the highest value a created soldier can have (1 is the smallest value)   maxDamage represents the highest damage a soldier can do (1 is the smallest value)   Each soldier in generate Army1 is created by :   -generating a random number between 1 and the maxSoldierHealth for the hp   -generatring a random number between 1 and the maxDamage for the damage.   Once a Soldier object is created, it is added to the end (back) of the linked list   “generateArmy2 “ creates and adds soldiers to army2 (linked list) in a similar fashion as above.   SimulateWar() performs the Battle sequence outlined on the next page.   showArmyOne() shows the hp and damage of each soldier in army 1.   showArmyTwo() shows the hp and damage of each soldier in army 2.   Battle sequence for simulateWar:   One soldier is removed from the front of each army. These two engage based on the Combat sequence outlined below. The survivor is then added to the back of their army. If one army has no more soldier, the battle is over.   Combat sequence of a fight between 2 soldiers:   The fight continues until the army1 soldier or army2 soldier has HP of 0 or less.   The fight is broken up into rounds (similar to our previous labs)   At the start of each round:   1) A random roll out of 100 is done:   If the roll is 50 -100, the army1 soldier attacks first (army1 soldier is the attacker, the army2 soldier is the defender)   If the roll is 1 - 49, the army2 soldier attacks first (army2 soldier is the attacker, the army1 soldier is the defender)   2) The attacker makes a random roll out of 100.   a. If the roll if 50-100, the attacker hits and does their full damage to the defender   b. If the roll is 1-49, the attacker misses   3) If the defender is still alive , the defender makes a random roll out of 100.   a. If the roll if 50-100, the defender hits and does their full damage to the attacker   b. If the roll is 1-49, the defender misses   These steps are repeated until the fight ends.   The surviving soldier is added to the end of the respective army’s list.   The Battle ends when one army has no more soldiers to fight.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

 

The question is below. I am also attaching 2 pictures. This is not graded and please make sure to read what I asked. I can upload a doc of the question so I have copy pasted the question. 

 

 

 

PLEASE make sure the c++ code works in visual studios 

 

 

 

 

 

 

 

Scenario: Two armies go to war. However there is a single bridge that connects both armies. Only one soldier from each army can fit on the bridge at a time.

 

Objective: Simulate a simple battle between the two armies.

 

Restrictions:

 

The soldiers in each army are created with random stats

 

The soldiers fight one at a time

 

Process:

 

Step 1: Create a Soldier class as outlined below.

 

Function “takeDamage” takes an integer and reduce the soldiers hp by that amount.

 

Step 2 : create a WarData class

 

WarData() -> creates the two armies as linked lists (using the STL)

 

“generateArmy1 “ creates and adds soldiers to army1 (linked list)

 

 num represents the number of soldiers to be created

 

maxSoldierHealth represents the highest value a created soldier can have (1 is the smallest value)

 

maxDamage represents the highest damage a soldier can do (1 is the smallest value)

 

Each soldier in generate Army1 is created by :

 

-generating a random number between 1 and the maxSoldierHealth for the hp

 

-generatring a random number between 1 and the maxDamage for the damage.

 

Once a Soldier object is created, it is added to the end (back) of the linked list

 

“generateArmy2 “ creates and adds soldiers to army2 (linked list) in a similar fashion as above.

 

SimulateWar() performs the Battle sequence outlined on the next page.

 

showArmyOne() shows the hp and damage of each soldier in army 1.

 

showArmyTwo() shows the hp and damage of each soldier in army 2.

 

Battle sequence for simulateWar:

 

One soldier is removed from the front of each army. These two engage based on the Combat sequence outlined below. The survivor is then added to the back of their army. If one army has no more soldier, the battle is over.

 

Combat sequence of a fight between 2 soldiers:

 

The fight continues until the army1 soldier or army2 soldier has HP of 0 or less.

 

The fight is broken up into rounds (similar to our previous labs)

 

At the start of each round:

 

1) A random roll out of 100 is done:

 

If the roll is 50 -100, the army1 soldier attacks first (army1 soldier is the attacker, the army2 soldier is the defender)

 

If the roll is 1 - 49, the army2 soldier attacks first (army2 soldier is the attacker, the army1 soldier is the defender)

 

2) The attacker makes a random roll out of 100.

 

a. If the roll if 50-100, the attacker hits and does their full damage to the defender

 

b. If the roll is 1-49, the attacker misses

 

3) If the defender is still alive , the defender makes a random roll out of 100.

 

a. If the roll if 50-100, the defender hits and does their full damage to the attacker

 

b. If the roll is 1-49, the defender misses

 

These steps are repeated until the fight ends.

 

The surviving soldier is added to the end of the respective army’s list.

 

The Battle ends when one army has no more soldiers to fight.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Step 2: create a WarData class
WarData
- army1: list<Soldier>
- army2: list<Soldier>
+ WarData()
+ generateArmy1 (num:int,maxSoldierHealth:int,maxDamage: int)
+ generateArmy2 (num:int,maxSoldierHealth:int,maxDamage: int)
simulateWar();
+ showArmyOne();
+ showArmyTwo();
Transcribed Image Text:Step 2: create a WarData class WarData - army1: list<Soldier> - army2: list<Soldier> + WarData() + generateArmy1 (num:int,maxSoldierHealth:int,maxDamage: int) + generateArmy2 (num:int,maxSoldierHealth:int,maxDamage: int) simulateWar(); + showArmyOne(); + showArmyTwo();
Process:
Step 1: Create a Soldier class as outlined below.
Soldier
- hp : int
- damage: int
+ Solder(hp:int,dam:int)
+ getHp(): int
+ getDamage():int
+ takeDamage(amt: int)
Function "takeDamage” takes an integer and reduce the soldiers
hp by that amount.
Transcribed Image Text:Process: Step 1: Create a Soldier class as outlined below. Soldier - hp : int - damage: int + Solder(hp:int,dam:int) + getHp(): int + getDamage():int + takeDamage(amt: int) Function "takeDamage” takes an integer and reduce the soldiers hp by that amount.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Running Time of Application
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education