-
Notifications
You must be signed in to change notification settings - Fork 0
/
creature.cpp
149 lines (149 loc) · 3.73 KB
/
creature.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
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*************************
* Program: creature.cpp
* Author: Kaitlin Hill
* Date: 5/12/17
* Description: creature setters and getters and the get damage
* Input: none
* Output: none
* **********************/
#include "./creature.h"
/*************************
* Function: creature
* Description: create creature
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
creature::creature(){
name = ' ';
strength = 0;
damage = 0;
strength = 0;
hit_points = 0;
cost = 0;
payoff = 0;
}
/*************************
* Function: get_name
* Description: accessor
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: name
* ************************/
string creature::get_name() const{
return name;
}
/*************************
* Function: set_name
* Description: mutator
* Parameters: new_name
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::set_name(string new_name){
name = new_name;
}
/*************************
* Function: set_damage
* Description: mutator
* Parameters: new_damage
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::set_damage(int new_damage){
damage = new_damage;
}
/*************************
* Function:get_hit_points
* Description: accessor
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: hit_points
* ************************/
int creature::get_hit_points() const{
return hit_points;
}
/*************************
* Function: set_hit_points
* Description: mutator
* Parameters: new_hit_points
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::set_hit_points(int new_hit_points){
hit_points = new_hit_points;
}
/*************************
* Function: get_payoff
* Description: accessor
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: payoff
* ************************/
int creature::get_payoff() const{
return payoff;
}
/*************************
* Function: set_payoff
* Description: mutator
* Parameters: new_payoff
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::set_payoff(int new_payoff){
payoff = new_payoff;
}
/*************************
* Function: get_cost
* Description: accessor
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: cost
* ************************/
int creature::get_cost() const{
return cost;
}
/*************************
* Function: set_cost
* Description: mutator
* Parameters: new_set_cost
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::set_cost(int new_set_cost){
cost = new_set_cost;
}
/*************************
* Function: get_damage
* Description: get damage
* Parameters: none
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: damage
* ************************/
int creature::get_damage(){
damage = (rand() % strength) +1;
cout << "Creature inflicts " << damage << " points!" << endl;
return damage;
}
/*************************
* Function: receive_damage
* Description: mutator
* Parameters: damage
* Pre-conditions: variables must have values
* Post-conditions: none
* Return: none
* ************************/
void creature::receive_damage(int damage){
hit_points = hit_points - damage;
}