d04 ex02 ok, presque rien a changer ou je me trompe ?

This commit is contained in:
hugogogo
2022-02-26 22:12:55 +01:00
parent ed2bbc7fd2
commit c056db80b7
27 changed files with 597 additions and 68 deletions

View File

@@ -0,0 +1,27 @@
#ifndef ANIMAL_HPP
# define ANIMAL_HPP
# include "color.h"
#include <iostream>
#include <string>
class Animal {
public:
Animal();
Animal( Animal const & src );
virtual ~Animal( void );
Animal & operator=( Animal const & rhs );
virtual void makeSound() const = 0;
std::string getType() const;
protected:
std::string type;
};
#endif

View File

@@ -0,0 +1,30 @@
#ifndef BRAIN_HPP
# define BRAIN_HPP
#include "color.h"
#include <iostream>
#include <string>
#define SIZE_IDEAS 100
class Brain {
public:
Brain( void );
Brain( Brain const & src );
~Brain( void );
Brain & operator=( Brain const & rhs );
void printIdea(int pos);
void putIdea(int pos, std::string idea);
void printIdeas();
void putIdeas(std::string idea);
private:
std::string _ideas[SIZE_IDEAS];
};
#endif

34
d04/ex02/headers/Cat.hpp Normal file
View File

@@ -0,0 +1,34 @@
#ifndef CAT_HPP
# define CAT_HPP
# include "color.h"
# include <iostream>
# include <string>
# include "Animal.hpp"
# include "Brain.hpp"
class Cat : public Animal {
public:
Cat();
Cat( Brain *brain );
// Cat( Brain *brain = new Brain() );
Cat( Cat const & src );
~Cat();
Cat & operator=( Cat const & rhs );
void makeSound() const;
void printBrain() const;
void printBrain(int pos) const;
private:
Brain *_brain;
};
#endif

30
d04/ex02/headers/Dog.hpp Normal file
View File

@@ -0,0 +1,30 @@
#ifndef DOG_HPP
# define DOG_HPP
# include "color.h"
# include <iostream>
# include <string>
# include "Animal.hpp"
# include "Brain.hpp"
class Dog : public Animal {
public:
Dog();
Dog( Brain *brain );
Dog( Dog const & src );
~Dog();
Dog & operator=( Dog const & rhs );
void makeSound() const;
private:
Brain *_brain;
};
#endif

24
d04/ex02/headers/color.h Normal file
View File

@@ -0,0 +1,24 @@
#ifndef COLOR_H
# define COLOR_H
# define GRAY "\e[0;30m"
# define RED "\e[0;31m"
# define GREEN "\e[0;32m"
# define YELLOW "\e[0;33m"
# define BLUE "\e[0;34m"
# define PURPLE "\e[0;35m"
# define CYAN "\e[0;36m"
# define WHITE "\e[0;37m"
# define B_GRAY "\e[1;30m"
# define B_RED "\e[1;31m"
# define B_GREEN "\e[1;32m"
# define B_YELLOW "\e[1;33m"
# define B_BLUE "\e[1;34m"
# define B_PURPLE "\e[1;35m"
# define B_CYAN "\e[1;36m"
# define B_WHITE "\e[1;37m"
# define RESET "\e[0m"
#endif