-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAnimal.cpp
160 lines (114 loc) · 3.07 KB
/
Animal.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
150
151
152
153
154
155
156
157
158
159
160
/*********************************************************************
** Author: Karen Berba
** Date: 1/27/19
** Description:
Animal class
Animal class is the parent/base class for Tiger class, Penguin class, and Turtle class.
Animal class
- Protected
- Static constexpr double base food cost
- Age, babies, starting cost, food cost, payoff
- Public
- Setters
- Set age, babies, starting cost, food cost, payoff
- Getters
- Get age, babies, starting cost, food cost, payoff
- Other functions
- Animal aging function
- Default constructor
- Custom constructor that takes in an integer age
NOTES:
Age
Adult if age >= 3 days
Baby if age < 3 days
** babies start at 0 days old
** newly bought animals start at 1 day old
*** Dead animals will be set -1 days old
*********************************************************************/
#include "Animal.hpp"
/*********************************************************************
**
SETTERS
Description:
Setters for animalAge, numBabies, initialCost, foodCost, and payoff.
Arguments:
Integers and doubles.
Restrictions:
Only integers and doubles.
Returns:
Does not return anything.
*********************************************************************/
void Animal::setAge(int numAge) {
animalAge = numAge;
}
void Animal::setNumBabies(int baby) {
numBabies = baby;
}
void Animal::setInitialCost(double icost) {
initialCost = icost;
}
void Animal::setFoodCost(double fcost) {
foodCost = fcost;
}
void Animal::setPayoff(double pay) {
payoff = pay;
}
/*********************************************************************
**
GETTERS
Description:
Getters for animalAge, numBabies, initialCost, foodCost, and payoff.
Arguments:
No arguments.
Restrictions:
No restrictions.
Returns:
Returns integers and doubles of the variables.
*********************************************************************/
int Animal::getAge() {
return animalAge;
}
int Animal::getNumBabies() {
return numBabies;
}
double Animal::getInitialCost() {
return initialCost;
}
double Animal::getFoodCost() {
return foodCost;
}
double Animal::getPayoff() {
return payoff;
}
/*********************************************************************
**
DEFAULT CONSTRUCTOR
*********************************************************************/
Animal::Animal() {
setAge(0); // initial age for baby animal
}
/*********************************************************************
**
CUSTOM CONSTRUCTOR
*********************************************************************/
Animal::Animal(int aAge) {
setAge(aAge); // age for newly bought adult
}
/*********************************************************************
**
int Animal::animalAging()
Description:
Adds 1 day to the animal's current age.
Arguments:
No arguments.
Restrictions:
Only integers.
Returns:
Integer animalAge.
*********************************************************************/
int Animal::animalAging() {
// adds 1 day to the animal's current age
animalAge += 1;
// returns the new animal age
return animalAge;
}