-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathmain.cpp
44 lines (34 loc) · 1.01 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
* File: main.cpp
* Author: Javier <[email protected]>
*
* Created on September 25, 2017, 3:19 PM
*/
#include <cstdlib>
#include <iostream>
#include "Weapon.h"
#include "WeaponFactory.h"
using namespace std;
/**
* Simulates the behavior of a weapon in the presence and absence of armor, by
* printing its damage on standard output.
* @param weapon Weapon to simulate
* @param armor Armor points
*/
void simulateWeapon(Weapon * weapon, double armor) {
cout << weapon->getName() << " inflicts " << weapon->hit() << " when armor is 0" << std::endl;
cout << weapon->getName() << " inflicts " << weapon->hit(armor) << " when armor is " << armor << std::endl << std::endl;
}
/*
*
*/
int main(int argc, char** argv) {
double armor = 29;
Weapon *weapon = WeaponFactory::getInstance()->getWeapon("sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("spear");
simulateWeapon(weapon, armor);
delete(weapon);
return 0;
}