From 1c1e515ceb772f97fa2a28053f6a8eded9001c4e Mon Sep 17 00:00:00 2001 From: Raphael Date: Fri, 31 Jan 2025 18:02:30 +0100 Subject: [PATCH] style: respecting the order of the file --- cpp04/Animal.cpp | 0 cpp04/Cat.cpp | 0 cpp04/Dog.cpp | 0 cpp04/ex00/Animal.cpp | 32 ++++++++++++++++++++++++++++++++ cpp04/{ => ex00}/Animal.hpp | 12 +++++++++--- cpp04/ex00/Cat.cpp | 26 ++++++++++++++++++++++++++ cpp04/{ => ex00}/Cat.hpp | 15 ++++++++++++++- cpp04/ex00/Dog.cpp | 26 ++++++++++++++++++++++++++ cpp04/{ => ex00}/Dog.hpp | 16 +++++++++++++++- cpp04/{ => ex00}/Makefile | 0 cpp04/{ => ex00}/main.cpp | 14 +++++++++++--- 11 files changed, 133 insertions(+), 8 deletions(-) delete mode 100644 cpp04/Animal.cpp delete mode 100644 cpp04/Cat.cpp delete mode 100644 cpp04/Dog.cpp create mode 100644 cpp04/ex00/Animal.cpp rename cpp04/{ => ex00}/Animal.hpp (82%) create mode 100644 cpp04/ex00/Cat.cpp rename cpp04/{ => ex00}/Cat.hpp (82%) create mode 100644 cpp04/ex00/Dog.cpp rename cpp04/{ => ex00}/Dog.hpp (80%) rename cpp04/{ => ex00}/Makefile (100%) rename cpp04/{ => ex00}/main.cpp (71%) diff --git a/cpp04/Animal.cpp b/cpp04/Animal.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/cpp04/Cat.cpp b/cpp04/Cat.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/cpp04/Dog.cpp b/cpp04/Dog.cpp deleted file mode 100644 index e69de29..0000000 diff --git a/cpp04/ex00/Animal.cpp b/cpp04/ex00/Animal.cpp new file mode 100644 index 0000000..410e2e7 --- /dev/null +++ b/cpp04/ex00/Animal.cpp @@ -0,0 +1,32 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Animal.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/01/30 13:21:01 by rparodi #+# #+# */ +/* Updated: 2025/01/30 13:37:51 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "Animal.hpp" +#include + +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; +} diff --git a/cpp04/Animal.hpp b/cpp04/ex00/Animal.hpp similarity index 82% rename from cpp04/Animal.hpp rename to cpp04/ex00/Animal.hpp index dd182e2..bcd273a 100644 --- a/cpp04/Animal.hpp +++ b/cpp04/ex00/Animal.hpp @@ -6,18 +6,24 @@ /* 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 #define ANIMAL_HPP +#include +#include + class Animal { public: - + Animal(); + ~Animal(); + void makeSound(); + std::string getType(); protected: - + std::string type; private: }; diff --git a/cpp04/ex00/Cat.cpp b/cpp04/ex00/Cat.cpp new file mode 100644 index 0000000..207c674 --- /dev/null +++ b/cpp04/ex00/Cat.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Cat.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/cpp04/Cat.hpp b/cpp04/ex00/Cat.hpp similarity index 82% rename from cpp04/Cat.hpp rename to cpp04/ex00/Cat.hpp index ecb50ba..130e8ed 100644 --- a/cpp04/Cat.hpp +++ b/cpp04/ex00/Cat.hpp @@ -6,11 +6,24 @@ /* 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 #define CAT_HPP +#include "Animal.hpp" +#include + +class Cat : public Animal { + public: + Cat(); + ~Cat(); + protected: + + private: + +}; + #endif diff --git a/cpp04/ex00/Dog.cpp b/cpp04/ex00/Dog.cpp new file mode 100644 index 0000000..cf6a045 --- /dev/null +++ b/cpp04/ex00/Dog.cpp @@ -0,0 +1,26 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* Dog.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* 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); +} diff --git a/cpp04/Dog.hpp b/cpp04/ex00/Dog.hpp similarity index 80% rename from cpp04/Dog.hpp rename to cpp04/ex00/Dog.hpp index 18c5702..80c5361 100644 --- a/cpp04/Dog.hpp +++ b/cpp04/ex00/Dog.hpp @@ -6,11 +6,25 @@ /* 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 #define DOG_HPP +#include "Animal.hpp" +#include + +class Dog : public Animal { + public: + Dog(); + ~Dog(); + std::string getType(); + protected: + + private: + +}; + #endif diff --git a/cpp04/Makefile b/cpp04/ex00/Makefile similarity index 100% rename from cpp04/Makefile rename to cpp04/ex00/Makefile diff --git a/cpp04/main.cpp b/cpp04/ex00/main.cpp similarity index 71% rename from cpp04/main.cpp rename to cpp04/ex00/main.cpp index c991ed6..abfe447 100644 --- a/cpp04/main.cpp +++ b/cpp04/ex00/main.cpp @@ -6,7 +6,7 @@ /* 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 "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; }