-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDog.cpp
More file actions
57 lines (49 loc) · 1.77 KB
/
Copy pathDog.cpp
File metadata and controls
57 lines (49 loc) · 1.77 KB
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Dog.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: eelaine <eelaine@student.hive.fi> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/06/23 12:03:49 by eelaine #+# #+# */
/* Updated: 2025/07/24 17:15:38 by eelaine ### ########.fr */
/* */
/* ************************************************************************** */
#include "Dog.hpp"
#include "Brain.hpp"
Dog::Dog() : AAnimal("Dog") {
std::cout << "Dog default constructor called\n";
brain_ = new Brain();
}
Dog::Dog(const Dog ©) : AAnimal(copy) {
std::cout << "Dog copy constructor called\n";
brain_ = new Brain(*copy.brain_);
}
Dog& Dog::operator=(const Dog &other) {
std::cout << "Dog copy assignment operator called\n";
if (this != &other) {
AAnimal::operator=(other);
delete brain_;
brain_ = new Brain(*other.brain_);
}
return *this;
}
Dog::~Dog() {
delete brain_;
std::cout << "Dog destructor called\n";
}
void Dog::makeSound() const {
std::cout << type_ << ": *MEOWW*\n";
}
void Dog::setIdea(unsigned int n, std::string idea) {
if (n > 99)
std::cout << "Dog has too many ideas!\n";
else
brain_->ideas_[n] = idea;
}
std::string Dog::getIdea(unsigned int n) {
if (n > 99)
return "Dog has too many ideas!\n";
else
return brain_->ideas_[n];
}