-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathLazyBacteria.h
82 lines (71 loc) · 2.05 KB
/
LazyBacteria.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
#ifndef LAZYBACTERIA_H_
#define LAZYBACTERIA_H_
#include "Bacteria.h"
#define LAZY_ADULT_AGE_MULTIPLIER 2
#define LAZY_EATING_RATE_MULTIPLIER 2
/* LazyBacteria
*
* A bacteria that consumes food at half the rate of eatingRate
* and the actual adult age is twice the adultAge.
* When duplicating the currentAge and consumedFood do not change.
*/
class LazyBacteria: 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
*/
LazyBacteria( int bacteriaId, int eatingRate, int adultAge, int foodUnits );
/** Copy Constructor
*
* @param otherBacteria const LazyBacteria & - the LazyBacteria to be copied
*/
LazyBacteria(const LazyBacteria& otherBacteria);
/*
* Class operator=
*Utilizes Base class operator=.
*
* @param rightHandSide const LazyBacteria & the assigning bacteria
* @return LazyBacteria& reference to this LazyBacteria.
*/
LazyBacteria& operator=(const LazyBacteria &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 and consumedFood do not change.
* The Bacteria class fields are duplicated.
*
* Gives Ownership!
*
* @return Bacteria* a pointer to new bacteria of type LazyBacteria
*/
virtual Bacteria* clone();
/*
* print
* Prints to screen _name then calls the standard Bacteria::print()
*/
virtual void print() const;
/*
* Class Destructor
*/
virtual ~LazyBacteria();
private:
const static std::string _name; //Class display name
};
#endif