-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTiger.cpp
43 lines (32 loc) · 1.19 KB
/
Tiger.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
/*********************************************************************
** Author: Karen Berba
** Date: 1/27/19
** Description:
Tiger class
Inherits from Animal class. Has a default constructor and a custom constructor that takes in an integer age.
NOTES:
- Tiger cost $10,000
- Tigers have 1 baby
- Tigers have a feeding cost of 5 times the base cost
- A tiger’s payoff per day is 20% of their cost per animal. (not counting bonus)
*********************************************************************/
#include "Tiger.hpp"
/*
source(s):
https://www.learncpp.com/cpp-tutorial/114-constructors-and-initialization-of-derived-classes/
https://stackoverflow.com/questions/7405740/how-can-i-initialize-base-class-member-variables-in-derived-class-constructor
*/
// default constructor
Tiger::Tiger() : Animal(0) { // age is 0 for baby tigers
Tiger::setNumBabies(1);
Tiger::setInitialCost(10000);
Tiger::setFoodCost(5 * BASE_FOOD_COST);
Tiger::setPayoff(0.20 * 10000);
}
// custom constructor
Tiger::Tiger(int tAge) : Animal(tAge) { // for newly bought tigers
Tiger::setNumBabies(1);
Tiger::setInitialCost(10000);
Tiger::setFoodCost(5 * BASE_FOOD_COST);
Tiger::setPayoff(0.20 * 10000);
}