forked from CEN4020-FSU/Assignment1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
110 lines (81 loc) · 2.75 KB
/
main.cpp
File metadata and controls
110 lines (81 loc) · 2.75 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/*
* File: main.cpp
* Author: Javier <jrescobara@gmail.com>
*
* 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);
weapon = WeaponFactory::getInstance()->getWeapon("hammer");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
armor = 37;
weapon = WeaponFactory::getInstance()->getWeapon("hammer");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
armor = 45;
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
armor = 77;
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
armor = 128;
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
armor = 36;
weapon = WeaponFactory::getInstance()->getWeapon("crazy sword");
simulateWeapon(weapon, armor);
delete(weapon);
weapon = WeaponFactory::getInstance()->getWeapon("tonbogiri");
simulateWeapon(weapon, armor);
delete(weapon);
return 0;
}