62 lines
1.6 KiB
C++
62 lines
1.6 KiB
C++
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* Brain.cpp :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: aortigos <aortigos@student.42malaga.com +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2025/11/10 11:22:21 by aortigos #+# #+# */
|
|
/* Updated: 2025/11/10 20:43:06 by aortigos ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "Brain.hpp"
|
|
|
|
Brain::Brain()
|
|
{
|
|
std::cout << "Brain has been created" << std::endl;
|
|
int i = 0;
|
|
while (i < 100)
|
|
{
|
|
ideas[i++] = "Empty idea";
|
|
}
|
|
}
|
|
|
|
Brain::~Brain()
|
|
{
|
|
std::cout << "Brain has been destroyed" << std::endl;
|
|
}
|
|
|
|
Brain::Brain(const Brain &other)
|
|
{
|
|
std::cout << "Brain copied" << std::endl;
|
|
*this = other;
|
|
}
|
|
|
|
Brain& Brain::operator=(const Brain &other)
|
|
{
|
|
std::cout << "Brain copy assignment called" << std::endl;
|
|
if (this != &other)
|
|
{
|
|
int i = 0;
|
|
while (i < 100)
|
|
{
|
|
this->ideas[i] = other.ideas[i];
|
|
i++;
|
|
}
|
|
}
|
|
return (*this);
|
|
}
|
|
|
|
void Brain::setIdea(int i, const std::string &idea)
|
|
{
|
|
if (i >= 0 && i < 100)
|
|
ideas[i] = idea;
|
|
}
|
|
|
|
std::string Brain::getIdea(int i) const
|
|
{
|
|
if (i >= 0 && i < 100)
|
|
return (this->ideas[i]);
|
|
return ("Invalid idea");
|
|
} |