style: respecting the order of the file

This commit is contained in:
Raphael 2025-01-31 18:02:30 +01:00
parent dff7b8c37a
commit 1c1e515ceb
11 changed files with 133 additions and 8 deletions

View file

View file

View file

32
cpp04/ex00/Animal.cpp Normal file
View file

@ -0,0 +1,32 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Animal.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/30 13:21:01 by rparodi #+# #+# */
/* Updated: 2025/01/30 13:37:51 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "Animal.hpp"
#include <iostream>
Animal::Animal() {
std::cout << "[Animal] Creating the class" << std::endl;
type = "";
}
Animal::~Animal() {
std::cout << "[Animal] Deleting the class" << std::endl;
}
void Animal::makeSound() {
if (type.compare("Cat"))
std::cout << "🐱 | Meow Meow" << std::endl;
else if (type.compare("Dog"))
std::cout << "🐶 | Wouf Wouf" << std::endl;
else
std::cout << "🤔 | thinking how to make a sound" << std::endl;
}

View file

@ -6,18 +6,24 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/28 17:44:54 by rparodi #+# #+# */ /* Created: 2025/01/28 17:44:54 by rparodi #+# #+# */
/* Updated: 2025/01/28 18:08:16 by rparodi ### ########.fr */ /* Updated: 2025/01/30 13:42:23 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef ANIMAL_HPP #ifndef ANIMAL_HPP
#define ANIMAL_HPP #define ANIMAL_HPP
#include <string>
#include <iostream>
class Animal { class Animal {
public: public:
Animal();
~Animal();
void makeSound();
std::string getType();
protected: protected:
std::string type;
private: private:
}; };

26
cpp04/ex00/Cat.cpp Normal file
View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Cat.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/30 13:32:43 by rparodi #+# #+# */
/* Updated: 2025/01/30 13:38:46 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "Cat.hpp"
Cat::Cat() {
std::cout << "[Cat] Creating the class" << std::endl;
type = "Cat";
}
Cat::~Cat() {
std::cout << "[Cat] Deleting the class" << std::endl;
}
std::string Cat::getType() {
return (type);
}

View file

@ -6,11 +6,24 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/28 17:44:48 by rparodi #+# #+# */ /* Created: 2025/01/28 17:44:48 by rparodi #+# #+# */
/* Updated: 2025/01/28 17:45:44 by rparodi ### ########.fr */ /* Updated: 2025/01/30 13:41:27 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef CAT_HPP #ifndef CAT_HPP
#define CAT_HPP #define CAT_HPP
#include "Animal.hpp"
#include <string>
class Cat : public Animal {
public:
Cat();
~Cat();
protected:
private:
};
#endif #endif

26
cpp04/ex00/Dog.cpp Normal file
View file

@ -0,0 +1,26 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* Dog.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/30 13:40:30 by rparodi #+# #+# */
/* Updated: 2025/01/30 13:40:51 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "Dog.hpp"
Dog::Dog() {
std::cout << "[Dog] Creating the class" << std::endl;
type = "Dog";
}
Dog::~Dog() {
std::cout << "[Dog] Deleting the class" << std::endl;
}
std::string Dog::getType() {
return (type);
}

View file

@ -6,11 +6,25 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/28 17:44:51 by rparodi #+# #+# */ /* Created: 2025/01/28 17:44:51 by rparodi #+# #+# */
/* Updated: 2025/01/28 17:45:51 by rparodi ### ########.fr */ /* Updated: 2025/01/30 13:32:28 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
#ifndef DOG_HPP #ifndef DOG_HPP
#define DOG_HPP #define DOG_HPP
#include "Animal.hpp"
#include <string>
class Dog : public Animal {
public:
Dog();
~Dog();
std::string getType();
protected:
private:
};
#endif #endif

View file

@ -6,7 +6,7 @@
/* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */ /* By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2025/01/28 17:08:09 by rparodi #+# #+# */ /* Created: 2025/01/28 17:08:09 by rparodi #+# #+# */
/* Updated: 2025/01/28 17:10:11 by rparodi ### ########.fr */ /* Updated: 2025/01/30 13:12:32 by rparodi ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -14,6 +14,14 @@
#include "Dog.hpp" #include "Dog.hpp"
#include "Cat.hpp" #include "Cat.hpp"
int main(int argc, char *argv[]) { int main() {
const Animal* meta = new Animal();
const Animal* j = new Dog();
const Animal* i = new Cat();
std::cout << j->getType() << " " << std::endl;
std::cout << i->getType() << " " << std::endl;
i->makeSound(); //will output the cat sound!
j->makeSound();
meta->makeSound();
return 0;
} }