BattleArena Documentation - jordoncotton/IntrotoC- GitHub Wiki
Battle Arena Documentation
Jordon Cotton
s188044
Introduction to C++
Prog101
I. Requirements Documentation
1. Description of problem
Name: Battle Arena Game
Problem statement:
-
Design a solution that takes in stack classes to create two heroes Battling against one another.
Problem Specification:
-
The first hero from team 1 attacks a randomly selected member from team 2 The strength of the attack is a random value between the minimum and maximum attack value.
- A message similar to the following is displayed: “Iron Man attacks Captain America with Unibeam and inflicts 18 damage” (replacing the hero and attack names with the appropriate values).
-
The health of the defending hero is decreased by the appropriate amount.
- The first hero from team 2 attacks a randomly selected member from team 1.
-
Attack strength and output message are handled in the same way.
-
The remaining heroes from each team then alternate. I.e., hero 2 from team 1, then hero 2 from team 2, then hero 3 from team 1, and so on.
-
If any hero dies during an attack, a message to this effect is written to the console.
-
When all heroes have finished attacking, each team array is sorted. Heroes are arranged in the array in descending order according to health.
-
If all heroes in a team have died, a ‘Game Over’ message is written to the console. This message will say which team has won.
-
The game is paused until the user presses ‘enter’.
-
If the game is not over, the loop begins again.
1.1 Input Information
- N/A
1.3 Output Information
- The output will have two heros from a movie fight each other and will output there health, power and the heros name all at once and will come out with someone dead and a winner.
1.4 User Interface Information
- The only source of interaction the user needs to do is just press continue to restart and debug again to see who will win next.
Design Documentation
1. System Architecture Description
2. Information about the objects
Class Information
-
Name: Hero
-
Description: Takes in data for both "Heroes" and allows them to battle.
-
Base Class: N/A
-
Class Attributes
Name: mHealth
-
Description: Allows the heros to be leveled evenly out from start (fighting and having 100 HP) and having the ability to win or lose.
-
Type: int
-
Range of Acceptable Values: int values
-
Name: mPower
-
Description: Allows the hero to generate a ability, randomly to do certain amounts of damage to the other hero.
-
Type: int
-
Range of Acceptable Values: int values
-
Name: mName
-
Description: The Heros name.
-
Type: const char
-
Range of Acceptable Values: char values
-
Class Operations
Prototype: Fight(Hero&): void
-
Description: Allows the Hero to be assigned to another hero to fight the opponent "hero" and then will call the "TakeDamage" function.
-
Pre-conditions: Two Heros are alive and will be entitled to the Fight and Battle function.
-
Post-conditions: Both heros will Fight until either one is no longer alive.
-
Visibility: Public
-
Prototype: TakeDamage(int): void
-
Description: Takes away one heros HP from the int value of power.
-
Pre-conditions: Two Heros are alive and will be entitled to the Fight and Battle function.
-
Post-conditions: The Heros HP will lessen by the power value
-
Visibility: Public
-
Name: Stack
-
Description: Chooses a stack to carry the fighters in and puts them in a winner & loser spot.
-
Base Class: NA
-
Class Attribute
Name: mData[20];
-
Description: Stack Array that carries the Heros
-
Type: Hero*
-
Range of Acceptable Values: Both Heros
-
Name: mCount
-
Description: To keep trace of the current place in the array
-
Type: int
-
Range of Acceptable Values: int values from 0 to 20
-
Class Operation
Prototype: Stack()
-
Description: A function to position mCount to 0
-
Pre-Conditions: New case of Stack is being designed
-
Post-Conditions: New Stack is designed, with mCount positioned to 0
-
Visibility: Public
-
Prototype: bool Pop();
-
Description: Removes the top of the Stack and lessens mCount
-
Pre-Conditions: Stack is in and calls the function
-
Post-Conditions: Remove the Hero at the top of the stack, lessen mCount
-
Visibility: Public
-
Prototype: bool Push(Hero* h)
-
Description: Pushes a certain Hero to the top of the Stack calling the function
-
Pre-Conditions: A Hero and a Stack is in.
-
Post-Conditions: A certain hero is on top of the stack
-
Visibility: Public
-
Name: Game
Prototype: Battle (Hero&, Hero&): Hero
- Description: Designs a stack to carry the fighters on both sides including the winner & loser spot.
-
Base Class: NA
-
Type: Hero
-
Pre-Conditions: Two Heroes exist
-
Post-Conditions: New Resolution is created, storing winner and loser
-
Visibility: Public
-