30 lines
730 B
C++
30 lines
730 B
C++
|
|
#include "Animal.hpp"
|
||
|
|
#include <iostream>
|
||
|
|
|
||
|
|
Animal::Animal() { std::cout << __PRETTY_FUNCTION__ << std::endl; }
|
||
|
|
|
||
|
|
Animal::Animal(const Animal &other) {
|
||
|
|
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
||
|
|
type = other.type;
|
||
|
|
}
|
||
|
|
|
||
|
|
Animal::~Animal() { std::cout << __PRETTY_FUNCTION__ << std::endl; }
|
||
|
|
|
||
|
|
Animal &Animal::operator=(const Animal &other) {
|
||
|
|
std::cout << __PRETTY_FUNCTION__ << std::endl;
|
||
|
|
this->type = other.type;
|
||
|
|
return *this;
|
||
|
|
}
|
||
|
|
|
||
|
|
std::string Animal::getType() const { return type; }
|
||
|
|
|
||
|
|
void Animal::makeSound() const {
|
||
|
|
if (type == "Cat") {
|
||
|
|
std::cout << "[Meow]" << std::endl;
|
||
|
|
} else if (type == "Dog") {
|
||
|
|
std::cout << "[Bark]" << std::endl;
|
||
|
|
} else {
|
||
|
|
std::cout << "[Generic Animal Sound]" << std::endl;
|
||
|
|
}
|
||
|
|
}
|