-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHungryBacteria.h
83 lines (71 loc) · 2.08 KB
/
HungryBacteria.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
#ifndef HUNGRYBACTERIA_H_
#define HUNGRYBACTERIA_H_
#include "Bacteria.h"
#define HUNGRY_FOOD_UNITS_MULTIPLIER 2
#define HUNGRY_CURRENT_AGE_MULTIPLIER 0.5
/* HungryBacteria
*
* A bacteria that consumes food twice as much as
* how much was ate last time.
* When duplicating- the currentAge is halved and consumedFood reset to 0.
*/
class HungryBacteria: 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
*/
HungryBacteria( int bacteriaId, int eatingRate, int adultAge, int foodUnits );
/** Copy Constructor
*
* @param otherBacteria const HungryBacteria & - the HungryBacteria to be copied
*/
HungryBacteria(const HungryBacteria& otherBacteria);
/*
* Class operator=
*Utilizes Base class operator=.
*
* @param rightHandSide const HungryBacteria & the assigning bacteria
* @return HungryBacteria& reference to this HungryBacteria.
*/
HungryBacteria& operator=(const HungryBacteria &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.
*
* @return Bacteria* a pointer to new bacteria of type HungryBacteria
*
* Gives Ownership!
*/
virtual Bacteria* clone();
/*
* print
* Prints to screen _name then calls the standard Bacteria::print()
*/
virtual void print() const;
/*
* Class Destructor
*/
virtual ~HungryBacteria();
private:
const static std::string _name; //Class display name
};
#endif