-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathDieteticBacteria.h
85 lines (74 loc) · 2.18 KB
/
DieteticBacteria.h
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
#ifndef DIETETICBACTERIA_H_
#define DIETETICBACTERIA_H_
#include "Bacteria.h"
#define DIETETIC_FOOD_UNITS_MULTIPLIER 0.5
#define DIETETIC_CURRENT_AGE_MULTIPLIER 2
#define DIETETIC_CONSUMED_FOOD_MULTIPLIER 0.5
/* DieteticBacteria
*
* A Bacteria that consumes food (foodUnits) half as much as
* how much was ate last time
* When duplicating the currentAge is reset to 0 and consumedFood is halved.
*/
class DieteticBacteria: public Bacteria{
public:
/*
* Class Constructor
*
* @param bacteriaId int the new bacteria ID
* @param eatingRate int the eating rate of the bacteria
* @param adultAge int the age in which the bacteria is eligble to clone
* @param foodUnits int number of food units the bacteria will consume
*/
DieteticBacteria( int bacteriaId, int eatingRate,
int adultAge, int foodUnits );
/** Copy Constructor
*
* @param otherBacteria const DieteticBacteria & - the DieteticBacteria to be copied
*
*/
DieteticBacteria(const DieteticBacteria& otherBacteria);
/*
* Class operator=
*Utilizes Base class operator=.
*
* @param rightHandSide const DieteticBacteria & the assigning bacteria
* @return DieteticBacteria& reference to this DieteticBacteria.
*/
DieteticBacteria& operator=(const DieteticBacteria &rightHandSide)
{
if (this == &rightHandSide) return *this;
Bacteria::operator=(rightHandSide);
return(*this);
}
/*
* clone
* Used to create a duplicate bacteria
* according to general bacteria and specific class definitions.
* First checks whether bacteria is ready to clone using
* the Bacteria::isReadyToClone() function.
*
* If the bacteria is not ready for cloning (above check does not pass)
* then returns NULL.
*
* When duplicating the currentAge is reset to 0 and consumedFood is halved.
* The Bacteria class fields are duplicated.
*
* Gives Ownership!
*
* @return Bacteria* a pointer to new bacteria of type DieteticBacteria
*/
virtual Bacteria* clone();
/*
* print
* Prints to screen _name then calls the standard Bacteria::print()
*/
virtual void print() const;
/*
* Class Destructor
*/
virtual ~DieteticBacteria();
private:
const static std::string _name; //Class display name
};
#endif