-
Notifications
You must be signed in to change notification settings - Fork 0
/
Brain.cpp
60 lines (49 loc) · 1.93 KB
/
Brain.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Brain.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abensett <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/04/28 04:10:35 by abensett #+# #+# */
/* Updated: 2022/06/16 03:20:44 by abensett ### ########.fr */
/* */
/* ************************************************************************** */
#include "Brain.hpp"
#include <sstream>
using std::cout;
using std::endl;
// TO STRING VERSION SSSTREAM -> C++ 98 et non C++11
static std::string toString(int i) {
std::stringstream ss;
ss << i;
return ss.str();
}
// Default Constructor
Brain::Brain(void) {
cout << "Brain constructor was called" << endl;
for (int i = 0; i < 100; i++)
_ideas[i] = "Ramdom idea " + toString(rand() % 100);
}
// Destructor
Brain::~Brain(void) {
cout << "Brain was deconstructed" << endl;
}
// Copy Constructor
Brain::Brain(const Brain &Brain) {
for ( int i = 0; i < 100; i++)
_ideas[i] = Brain._ideas[i];
*this = Brain;
}
// Copy Assignment Operator
Brain &Brain::operator=(const Brain &Brain) {
cout << "Brain ideas were copied" << endl;
if (this != &Brain) {
for ( int i = 0; i < 100; i++)
_ideas[i] = Brain._ideas[i];
}
return *this;
}
void Brain::printFirstIdeas(void) const {
cout << "IDEAS :" << _ideas[0] << "," << _ideas[1] << "," << _ideas[2] << "," << _ideas[3] << "," << _ideas[4] << endl;
}