From 01d94fd3f4e9fe93bffa81fb83a2ebe0cd54cdeb Mon Sep 17 00:00:00 2001 From: Alice Duvillier Date: Tue, 12 May 2026 12:13:37 +0200 Subject: [PATCH 1/3] add: starting IPizza and factory, adding Americana --- src/Pizza/Americana.hpp | 26 +++++++++++++++++ src/Pizza/Fantasia.hpp | 25 ++++++++++++++++ src/Pizza/IPizza.hpp | 53 ++++++++++++++++++++++++++++++++++ src/Pizza/Margarita.hpp | 29 +++++++++++++++++++ src/Pizza/PizzaFactory.hpp | 33 +++++++++++++++++++++ src/Pizza/Regina.hpp | 26 +++++++++++++++++ src/Pizza/cpp/Americana.cpp | 18 ++++++++++++ src/Pizza/cpp/PizzaFactory.cpp | 50 ++++++++++++++++++++++++++++++++ 8 files changed, 260 insertions(+) create mode 100644 src/Pizza/Americana.hpp create mode 100644 src/Pizza/Fantasia.hpp create mode 100644 src/Pizza/IPizza.hpp create mode 100644 src/Pizza/Margarita.hpp create mode 100644 src/Pizza/PizzaFactory.hpp create mode 100644 src/Pizza/Regina.hpp create mode 100644 src/Pizza/cpp/Americana.cpp create mode 100644 src/Pizza/cpp/PizzaFactory.cpp diff --git a/src/Pizza/Americana.hpp b/src/Pizza/Americana.hpp new file mode 100644 index 0000000..672abc6 --- /dev/null +++ b/src/Pizza/Americana.hpp @@ -0,0 +1,26 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** Americana +*/ + +#ifndef AMERICANA_HPP_ +#define AMERICANA_HPP_ + +#include "IPizza.hpp" + +namespace plazza { + class Americana : public IPizza { + public: + Americana(PizzaSize size); + ~Americana(); + + protected: + private: + PizzaSize _size; + Ingredients _ingredients; + }; +} + +#endif /* !AMERICANA_HPP_ */ diff --git a/src/Pizza/Fantasia.hpp b/src/Pizza/Fantasia.hpp new file mode 100644 index 0000000..682491e --- /dev/null +++ b/src/Pizza/Fantasia.hpp @@ -0,0 +1,25 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** Fantasia +*/ + +#ifndef FANTASIA_HPP_ +#define FANTASIA_HPP_ + +#include "IPizza.hpp" + +namespace plazza { + class Fantasia : public IPizza { + public: + Fantasia(PizzaSize size); + ~Fantasia(); + + protected: + private: + PizzaSize _size; + }; +} + +#endif /* !FANTASIA_HPP_ */ diff --git a/src/Pizza/IPizza.hpp b/src/Pizza/IPizza.hpp new file mode 100644 index 0000000..e148224 --- /dev/null +++ b/src/Pizza/IPizza.hpp @@ -0,0 +1,53 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** IPizza +*/ + +#ifndef IPIZZA_HPP_ +#define IPIZZA_HPP_ + +#include +#include +#include + +enum Ingredients : uint16_t { + AUCUN = 0, + DOUGH = 1 << 0, + TOMATO = 1 << 1, + GRUYERE = 1 << 2, + HAM = 1 << 3, + MUSHROOMS = 1 << 4, + STEAK = 1 << 5, + EGGPLANT = 1 << 6, + GOATCHEESE = 1 << 7, + CHIEFLOVE = 1 << 8, +}; + +enum PizzaType { + Regina = 1, + Margarita = 2, + Americana = 4, + Fantasia = 8 +}; + +enum PizzaSize { + S = 1, + M = 2, + L = 4, + XL = 8, + XXL = 16 +}; + +namespace plazza { + class IPizza { + public: + IPizza(PizzaSize size); + virtual ~IPizza() = default; + protected: + private: + }; +} + +#endif /* !IPIZZA_HPP_ */ diff --git a/src/Pizza/Margarita.hpp b/src/Pizza/Margarita.hpp new file mode 100644 index 0000000..39bf562 --- /dev/null +++ b/src/Pizza/Margarita.hpp @@ -0,0 +1,29 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** Margarita +*/ + +#ifndef MARGARITA_HPP_ +#define MARGARITA_HPP_ + +#include "IPizza.hpp" + +namespace plazza +{ + class Margarita : public IPizza { + public: + Margarita(PizzaSize size); + ~Margarita(); + + protected: + private: + PizzaSize _size; + }; +} // namespace plazza + + + + +#endif /* !MARGARITA_HPP_ */ diff --git a/src/Pizza/PizzaFactory.hpp b/src/Pizza/PizzaFactory.hpp new file mode 100644 index 0000000..224d8f1 --- /dev/null +++ b/src/Pizza/PizzaFactory.hpp @@ -0,0 +1,33 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** PizzaFactory +*/ + +#ifndef PIZZAFACTORY_HPP_ +#define PIZZAFACTORY_HPP_ + +#include "IPizza.hpp" +#include "Americana.hpp" +#include "Fantasia.hpp" +#include "Margarita.hpp" +#include "Regina.hpp" + +namespace plazza +{ + class PizzaFactory { + public: + + std::unique_ptr createPizza(PizzaType type, PizzaSize size); + + protected: + private: + std::unique_ptr createAmericana(PizzaSize size); + std::unique_ptr createFantasia(PizzaSize size); + std::unique_ptr createMargarita(PizzaSize size); + std::unique_ptr createRegina(PizzaSize size); + }; +} // namespace plazza + +#endif /* !PIZZAFACTORY_HPP_ */ diff --git a/src/Pizza/Regina.hpp b/src/Pizza/Regina.hpp new file mode 100644 index 0000000..5b14b22 --- /dev/null +++ b/src/Pizza/Regina.hpp @@ -0,0 +1,26 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** Regina +*/ + +#ifndef REGINA_HPP_ +#define REGINA_HPP_ + +#include "IPizza.hpp" + +namespace plazza +{ + class Regina : public IPizza { + public: + Regina(PizzaSize size); + ~Regina(); + + protected: + private: + PizzaSize _size; + }; +} // namespace plazza + +#endif /* !REGINA_HPP_ */ diff --git a/src/Pizza/cpp/Americana.cpp b/src/Pizza/cpp/Americana.cpp new file mode 100644 index 0000000..218ca81 --- /dev/null +++ b/src/Pizza/cpp/Americana.cpp @@ -0,0 +1,18 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** Americana +*/ + +#include "Americana.hpp" + +plazza::Americana::Americana(PizzaSize size) : IPizza(size) +{ + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | STEAK); +} + +plazza::Americana::~Americana() +{ +} diff --git a/src/Pizza/cpp/PizzaFactory.cpp b/src/Pizza/cpp/PizzaFactory.cpp new file mode 100644 index 0000000..8f07618 --- /dev/null +++ b/src/Pizza/cpp/PizzaFactory.cpp @@ -0,0 +1,50 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** PizzaFactory +*/ + +#include "PizzaFactory.hpp" + +std::unique_ptr plazza::PizzaFactory::createPizza(PizzaType type, PizzaSize size) +{ + switch (type) + { + case PizzaType::Americana: + return createAmericana(size); + break; + case PizzaType::Fantasia: + return createFantasia(size); + break; + case PizzaType::Margarita: + return createMargarita(size); + break; + case PizzaType::Regina: + return createRegina(size); + break; + default: + return nullptr; + break; + } +} + +std::unique_ptr plazza::PizzaFactory::createAmericana(PizzaSize size) +{ + return std::make_unique(size); +} + +std::unique_ptr plazza::PizzaFactory::createFantasia(PizzaSize size) +{ + return std::make_unique(size); +} + +std::unique_ptr plazza::PizzaFactory::createMargarita(PizzaSize size) +{ + return std::make_unique(size); +} + +std::unique_ptr plazza::PizzaFactory::createRegina(PizzaSize size) +{ + return std::make_unique(size); +} From afe14db997569411f154fb008cbc2c5eb731551b Mon Sep 17 00:00:00 2001 From: Alice Duvillier Date: Wed, 13 May 2026 14:02:27 +0200 Subject: [PATCH 2/3] up: Class Pizza, Factory finished - IPizza, IPizza, and Pizzas - functions: getSize(), getSizeString(), getIngredients(), getIngredientsList() - pizzas available: Margarita, Americana, Fantasia, Regina (all) --- .gitignore | 2 ++ Makefile | 4 ++- src/Pizza/APizza.cpp | 43 +++++++++++++++++++++++++ src/Pizza/APizza.hpp | 33 +++++++++++++++++++ src/Pizza/IPizza.hpp | 32 +++++++++++++++++- src/Pizza/{cpp => }/PizzaFactory.cpp | 0 src/Pizza/PizzaFactory.hpp | 10 +++--- src/Pizza/{cpp => Pizzas}/Americana.cpp | 2 +- src/Pizza/{ => Pizzas}/Americana.hpp | 7 ++-- src/Pizza/Pizzas/Fantasia.cpp | 11 +++++++ src/Pizza/{ => Pizzas}/Fantasia.hpp | 7 ++-- src/Pizza/Pizzas/Margarita.cpp | 11 +++++++ src/Pizza/{ => Pizzas}/Margarita.hpp | 7 ++-- src/Pizza/Pizzas/Regina.cpp | 11 +++++++ src/Pizza/{ => Pizzas}/Regina.hpp | 7 ++-- src/main.cpp | 17 +++++++++- 16 files changed, 178 insertions(+), 26 deletions(-) create mode 100644 src/Pizza/APizza.cpp create mode 100644 src/Pizza/APizza.hpp rename src/Pizza/{cpp => }/PizzaFactory.cpp (100%) rename src/Pizza/{cpp => Pizzas}/Americana.cpp (80%) rename src/Pizza/{ => Pizzas}/Americana.hpp (70%) create mode 100644 src/Pizza/Pizzas/Fantasia.cpp rename src/Pizza/{ => Pizzas}/Fantasia.hpp (76%) create mode 100644 src/Pizza/Pizzas/Margarita.cpp rename src/Pizza/{ => Pizzas}/Margarita.hpp (78%) create mode 100644 src/Pizza/Pizzas/Regina.cpp rename src/Pizza/{ => Pizzas}/Regina.hpp (77%) diff --git a/.gitignore b/.gitignore index c4869a6..36ce8b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ plazza .build +clang++ +.vscode \ No newline at end of file diff --git a/Makefile b/Makefile index f3b1a07..957fcde 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ MAKE_FLAGS += -j -SRC := $(wildcard src/*.cpp) +SRC := $(wildcard src/*.cpp) $(wildcard src/Pizza/*.cpp) $(wildcard src/Pizza/Pizzas/*.cpp) BUILD_DIR := .build @@ -11,6 +11,8 @@ CXXFLAGS += -Wformat=2 -Wshadow -fno-builtin -Wno-unused-command-line-argument CXXFLAGS += -Wstrict-aliasing=0 -Wunreachable-code CXXFLAGS += -Wwrite-strings -Werror=format-nonliteral -Werror=return-type CXXFLAGS += -std=c++20 -iquote src -iquote src/Server -iquote src/Client -iquote libs/myteams +CXXFLAGS += -Isrc/Pizza +CXXFLAGS += -Isrc/Pizza/Pizzas include utils.mk diff --git a/src/Pizza/APizza.cpp b/src/Pizza/APizza.cpp new file mode 100644 index 0000000..8eeb26f --- /dev/null +++ b/src/Pizza/APizza.cpp @@ -0,0 +1,43 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** APizza +*/ + +#include "APizza.hpp" + +plazza::APizza::APizza(PizzaSize size) : IPizza(size), _size(size) +{ +} + +plazza::APizza::~APizza() +{ +} + +PizzaSize plazza::APizza::getSize() const +{ + return _size; +} + +std::string plazza::APizza::getSizeString() const +{ + return sizeToString[_size]; +} + +Ingredients plazza::APizza::getIngredients() const +{ + return _ingredients; +} + +std::vector plazza::APizza::getIngredientsList() const +{ + std::vector listIngredients; + + for (uint16_t bit = 1; bit <= CHIEFLOVE; bit <<= 1) { + if (_ingredients & bit) { + listIngredients.push_back(ingredientsToString[static_cast(bit)]); + } + } + return listIngredients; +} diff --git a/src/Pizza/APizza.hpp b/src/Pizza/APizza.hpp new file mode 100644 index 0000000..865cbdc --- /dev/null +++ b/src/Pizza/APizza.hpp @@ -0,0 +1,33 @@ +/* +** EPITECH PROJECT, 2026 +** plazza +** File description: +** APizza +*/ + +#ifndef APIZZA_HPP_ +#define APIZZA_HPP_ + +#include "IPizza.hpp" + +namespace plazza { + class APizza : public plazza::IPizza { + public: + APizza(PizzaSize size); + ~APizza(); + + PizzaSize getSize() const override; + std::string getSizeString() const override; + + Ingredients getIngredients() const override; + std::vector getIngredientsList() const override; + + protected: + PizzaSize _size; + Ingredients _ingredients; + private: + }; +} + + +#endif /* !APIZZA_HPP_ */ diff --git a/src/Pizza/IPizza.hpp b/src/Pizza/IPizza.hpp index e148224..3a2125a 100644 --- a/src/Pizza/IPizza.hpp +++ b/src/Pizza/IPizza.hpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include enum Ingredients : uint16_t { AUCUN = 0, @@ -40,11 +42,39 @@ enum PizzaSize { XXL = 16 }; +static inline std::map sizeToString = { + {PizzaSize::S, "S"}, + {PizzaSize::M, "M"}, + {PizzaSize::L, "L"}, + {PizzaSize::XL, "XL"}, + {PizzaSize::XXL, "XXL"} +}; + +static inline std::map ingredientsToString = { + {DOUGH, "Dough"}, + {TOMATO, "Tomato"}, + {GRUYERE, "Gruyere"}, + {HAM, "Ham"}, + {MUSHROOMS, "Mushrooms"}, + {STEAK, "Steak"}, + {EGGPLANT, "Eggplant"}, + {GOATCHEESE, "Goat cheese"}, + {CHIEFLOVE, "Chief love"} +}; + + namespace plazza { class IPizza { public: - IPizza(PizzaSize size); + IPizza(PizzaSize size) {}; virtual ~IPizza() = default; + + virtual PizzaSize getSize() const = 0; + virtual std::string getSizeString() const = 0; + + virtual Ingredients getIngredients() const = 0; + virtual std::vector getIngredientsList() const = 0; + protected: private: }; diff --git a/src/Pizza/cpp/PizzaFactory.cpp b/src/Pizza/PizzaFactory.cpp similarity index 100% rename from src/Pizza/cpp/PizzaFactory.cpp rename to src/Pizza/PizzaFactory.cpp diff --git a/src/Pizza/PizzaFactory.hpp b/src/Pizza/PizzaFactory.hpp index 224d8f1..61dcd3e 100644 --- a/src/Pizza/PizzaFactory.hpp +++ b/src/Pizza/PizzaFactory.hpp @@ -19,14 +19,14 @@ namespace plazza class PizzaFactory { public: - std::unique_ptr createPizza(PizzaType type, PizzaSize size); + static std::unique_ptr createPizza(PizzaType type, PizzaSize size); protected: private: - std::unique_ptr createAmericana(PizzaSize size); - std::unique_ptr createFantasia(PizzaSize size); - std::unique_ptr createMargarita(PizzaSize size); - std::unique_ptr createRegina(PizzaSize size); + static std::unique_ptr createAmericana(PizzaSize size); + static std::unique_ptr createFantasia(PizzaSize size); + static std::unique_ptr createMargarita(PizzaSize size); + static std::unique_ptr createRegina(PizzaSize size); }; } // namespace plazza diff --git a/src/Pizza/cpp/Americana.cpp b/src/Pizza/Pizzas/Americana.cpp similarity index 80% rename from src/Pizza/cpp/Americana.cpp rename to src/Pizza/Pizzas/Americana.cpp index 218ca81..f03b1c1 100644 --- a/src/Pizza/cpp/Americana.cpp +++ b/src/Pizza/Pizzas/Americana.cpp @@ -7,7 +7,7 @@ #include "Americana.hpp" -plazza::Americana::Americana(PizzaSize size) : IPizza(size) +plazza::Americana::Americana(PizzaSize size) : APizza(size) { _size = size; _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | STEAK); diff --git a/src/Pizza/Americana.hpp b/src/Pizza/Pizzas/Americana.hpp similarity index 70% rename from src/Pizza/Americana.hpp rename to src/Pizza/Pizzas/Americana.hpp index 672abc6..b22c100 100644 --- a/src/Pizza/Americana.hpp +++ b/src/Pizza/Pizzas/Americana.hpp @@ -8,18 +8,15 @@ #ifndef AMERICANA_HPP_ #define AMERICANA_HPP_ -#include "IPizza.hpp" +#include "APizza.hpp" namespace plazza { - class Americana : public IPizza { + class Americana : public APizza { public: Americana(PizzaSize size); ~Americana(); - protected: private: - PizzaSize _size; - Ingredients _ingredients; }; } diff --git a/src/Pizza/Pizzas/Fantasia.cpp b/src/Pizza/Pizzas/Fantasia.cpp new file mode 100644 index 0000000..6d286fe --- /dev/null +++ b/src/Pizza/Pizzas/Fantasia.cpp @@ -0,0 +1,11 @@ +#include "Fantasia.hpp" + +plazza::Fantasia::Fantasia(PizzaSize size) : APizza(size) +{ + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | EGGPLANT | GOATCHEESE | CHIEFLOVE); +} + +plazza::Fantasia::~Fantasia() +{ +} diff --git a/src/Pizza/Fantasia.hpp b/src/Pizza/Pizzas/Fantasia.hpp similarity index 76% rename from src/Pizza/Fantasia.hpp rename to src/Pizza/Pizzas/Fantasia.hpp index 682491e..fc3e56f 100644 --- a/src/Pizza/Fantasia.hpp +++ b/src/Pizza/Pizzas/Fantasia.hpp @@ -8,17 +8,16 @@ #ifndef FANTASIA_HPP_ #define FANTASIA_HPP_ -#include "IPizza.hpp" +#include "APizza.hpp" + namespace plazza { - class Fantasia : public IPizza { + class Fantasia : public APizza { public: Fantasia(PizzaSize size); ~Fantasia(); - protected: private: - PizzaSize _size; }; } diff --git a/src/Pizza/Pizzas/Margarita.cpp b/src/Pizza/Pizzas/Margarita.cpp new file mode 100644 index 0000000..bfb6f1c --- /dev/null +++ b/src/Pizza/Pizzas/Margarita.cpp @@ -0,0 +1,11 @@ +#include "Margarita.hpp" + +plazza::Margarita::Margarita(PizzaSize size) : APizza(size) +{ + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | GRUYERE); +} + +plazza::Margarita::~Margarita() +{ +} diff --git a/src/Pizza/Margarita.hpp b/src/Pizza/Pizzas/Margarita.hpp similarity index 78% rename from src/Pizza/Margarita.hpp rename to src/Pizza/Pizzas/Margarita.hpp index 39bf562..b4d2584 100644 --- a/src/Pizza/Margarita.hpp +++ b/src/Pizza/Pizzas/Margarita.hpp @@ -8,18 +8,17 @@ #ifndef MARGARITA_HPP_ #define MARGARITA_HPP_ -#include "IPizza.hpp" +#include "APizza.hpp" + namespace plazza { - class Margarita : public IPizza { + class Margarita : public APizza { public: Margarita(PizzaSize size); ~Margarita(); - protected: private: - PizzaSize _size; }; } // namespace plazza diff --git a/src/Pizza/Pizzas/Regina.cpp b/src/Pizza/Pizzas/Regina.cpp new file mode 100644 index 0000000..ff265c2 --- /dev/null +++ b/src/Pizza/Pizzas/Regina.cpp @@ -0,0 +1,11 @@ +#include "Regina.hpp" + +plazza::Regina::Regina(PizzaSize size) : APizza(size) +{ + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | HAM | MUSHROOMS); +} + +plazza::Regina::~Regina() +{ +} diff --git a/src/Pizza/Regina.hpp b/src/Pizza/Pizzas/Regina.hpp similarity index 77% rename from src/Pizza/Regina.hpp rename to src/Pizza/Pizzas/Regina.hpp index 5b14b22..785756b 100644 --- a/src/Pizza/Regina.hpp +++ b/src/Pizza/Pizzas/Regina.hpp @@ -8,18 +8,17 @@ #ifndef REGINA_HPP_ #define REGINA_HPP_ -#include "IPizza.hpp" +#include "APizza.hpp" + namespace plazza { - class Regina : public IPizza { + class Regina : public APizza { public: Regina(PizzaSize size); ~Regina(); - protected: private: - PizzaSize _size; }; } // namespace plazza diff --git a/src/main.cpp b/src/main.cpp index f37d4ba..f55be93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,18 @@ #include +#include "PizzaFactory.hpp" -int main(void) { std::cout << "The Plazza, the best pizzeria" << std::endl; } +int main(void) +{ + std::cout << "The Plazza, the best pizzeria" << std::endl; + + auto americana = plazza::PizzaFactory::createPizza(PizzaType::Americana, PizzaSize::M); + + std::cout << "Americana, size: [" << americana->getSize() << "], ingredients: [" << americana->getIngredients() << "] !" << std::endl; + std::cout << "or..." << std::endl; + std::cout << "Americana, size: [" << americana->getSizeString() << "], ingredients: ["; + std::vector listIngredients = americana->getIngredientsList(); + for (size_t i = 0; i < listIngredients.size(); i++) { + std::cout << listIngredients[i] << ","; + } + std::cout << "] !" << std::endl; +} From e4fb9f979345274cb88f041a2cc4b12e812594f6 Mon Sep 17 00:00:00 2001 From: Alice Duvillier Date: Wed, 13 May 2026 14:10:53 +0200 Subject: [PATCH 3/3] fix: make format --- src/Pizza/APizza.cpp | 39 ++++++----------- src/Pizza/APizza.hpp | 28 ++++++------ src/Pizza/IPizza.hpp | 80 +++++++++++++--------------------- src/Pizza/PizzaFactory.cpp | 63 +++++++++++++------------- src/Pizza/PizzaFactory.hpp | 27 ++++++------ src/Pizza/Pizzas/Americana.cpp | 11 ++--- src/Pizza/Pizzas/Americana.hpp | 17 ++++---- src/Pizza/Pizzas/Fantasia.cpp | 12 +++-- src/Pizza/Pizzas/Fantasia.hpp | 18 ++++---- src/Pizza/Pizzas/Margarita.cpp | 11 ++--- src/Pizza/Pizzas/Margarita.hpp | 22 ++++------ src/Pizza/Pizzas/Regina.cpp | 12 +++-- src/Pizza/Pizzas/Regina.hpp | 17 ++++---- src/main.cpp | 29 ++++++------ 14 files changed, 172 insertions(+), 214 deletions(-) diff --git a/src/Pizza/APizza.cpp b/src/Pizza/APizza.cpp index 8eeb26f..15e7d55 100644 --- a/src/Pizza/APizza.cpp +++ b/src/Pizza/APizza.cpp @@ -7,37 +7,26 @@ #include "APizza.hpp" -plazza::APizza::APizza(PizzaSize size) : IPizza(size), _size(size) -{ -} +plazza::APizza::APizza(PizzaSize size) : IPizza(size), _size(size) {} -plazza::APizza::~APizza() -{ -} +plazza::APizza::~APizza() {} -PizzaSize plazza::APizza::getSize() const -{ - return _size; -} +PizzaSize plazza::APizza::getSize() const { return _size; } -std::string plazza::APizza::getSizeString() const -{ - return sizeToString[_size]; +std::string plazza::APizza::getSizeString() const { + return sizeToString[_size]; } -Ingredients plazza::APizza::getIngredients() const -{ - return _ingredients; -} +Ingredients plazza::APizza::getIngredients() const { return _ingredients; } -std::vector plazza::APizza::getIngredientsList() const -{ - std::vector listIngredients; +std::vector plazza::APizza::getIngredientsList() const { + std::vector listIngredients; - for (uint16_t bit = 1; bit <= CHIEFLOVE; bit <<= 1) { - if (_ingredients & bit) { - listIngredients.push_back(ingredientsToString[static_cast(bit)]); - } + for (uint16_t bit = 1; bit <= CHIEFLOVE; bit <<= 1) { + if (_ingredients & bit) { + listIngredients.push_back( + ingredientsToString[static_cast(bit)]); } - return listIngredients; + } + return listIngredients; } diff --git a/src/Pizza/APizza.hpp b/src/Pizza/APizza.hpp index 865cbdc..5b98e2c 100644 --- a/src/Pizza/APizza.hpp +++ b/src/Pizza/APizza.hpp @@ -11,23 +11,23 @@ #include "IPizza.hpp" namespace plazza { - class APizza : public plazza::IPizza { - public: - APizza(PizzaSize size); - ~APizza(); +class APizza : public plazza::IPizza { +public: + APizza(PizzaSize size); + ~APizza(); - PizzaSize getSize() const override; - std::string getSizeString() const override; + PizzaSize getSize() const override; + std::string getSizeString() const override; - Ingredients getIngredients() const override; - std::vector getIngredientsList() const override; + Ingredients getIngredients() const override; + std::vector getIngredientsList() const override; - protected: - PizzaSize _size; - Ingredients _ingredients; - private: - }; -} +protected: + PizzaSize _size; + Ingredients _ingredients; +private: +}; +} // namespace plazza #endif /* !APIZZA_HPP_ */ diff --git a/src/Pizza/IPizza.hpp b/src/Pizza/IPizza.hpp index 3a2125a..d2d814a 100644 --- a/src/Pizza/IPizza.hpp +++ b/src/Pizza/IPizza.hpp @@ -9,75 +9,57 @@ #define IPIZZA_HPP_ #include -#include #include #include +#include #include enum Ingredients : uint16_t { - AUCUN = 0, - DOUGH = 1 << 0, - TOMATO = 1 << 1, - GRUYERE = 1 << 2, - HAM = 1 << 3, - MUSHROOMS = 1 << 4, - STEAK = 1 << 5, - EGGPLANT = 1 << 6, - GOATCHEESE = 1 << 7, - CHIEFLOVE = 1 << 8, + AUCUN = 0, + DOUGH = 1 << 0, + TOMATO = 1 << 1, + GRUYERE = 1 << 2, + HAM = 1 << 3, + MUSHROOMS = 1 << 4, + STEAK = 1 << 5, + EGGPLANT = 1 << 6, + GOATCHEESE = 1 << 7, + CHIEFLOVE = 1 << 8, }; -enum PizzaType { - Regina = 1, - Margarita = 2, - Americana = 4, - Fantasia = 8 -}; +enum PizzaType { Regina = 1, Margarita = 2, Americana = 4, Fantasia = 8 }; -enum PizzaSize { - S = 1, - M = 2, - L = 4, - XL = 8, - XXL = 16 -}; +enum PizzaSize { S = 1, M = 2, L = 4, XL = 8, XXL = 16 }; static inline std::map sizeToString = { {PizzaSize::S, "S"}, {PizzaSize::M, "M"}, {PizzaSize::L, "L"}, {PizzaSize::XL, "XL"}, - {PizzaSize::XXL, "XXL"} -}; + {PizzaSize::XXL, "XXL"}}; static inline std::map ingredientsToString = { - {DOUGH, "Dough"}, - {TOMATO, "Tomato"}, - {GRUYERE, "Gruyere"}, - {HAM, "Ham"}, - {MUSHROOMS, "Mushrooms"}, - {STEAK, "Steak"}, - {EGGPLANT, "Eggplant"}, - {GOATCHEESE, "Goat cheese"}, - {CHIEFLOVE, "Chief love"} -}; - + {DOUGH, "Dough"}, {TOMATO, "Tomato"}, + {GRUYERE, "Gruyere"}, {HAM, "Ham"}, + {MUSHROOMS, "Mushrooms"}, {STEAK, "Steak"}, + {EGGPLANT, "Eggplant"}, {GOATCHEESE, "Goat cheese"}, + {CHIEFLOVE, "Chief love"}}; namespace plazza { - class IPizza { - public: - IPizza(PizzaSize size) {}; - virtual ~IPizza() = default; +class IPizza { +public: + IPizza(PizzaSize size){}; + virtual ~IPizza() = default; - virtual PizzaSize getSize() const = 0; - virtual std::string getSizeString() const = 0; + virtual PizzaSize getSize() const = 0; + virtual std::string getSizeString() const = 0; - virtual Ingredients getIngredients() const = 0; - virtual std::vector getIngredientsList() const = 0; + virtual Ingredients getIngredients() const = 0; + virtual std::vector getIngredientsList() const = 0; - protected: - private: - }; -} +protected: +private: +}; +} // namespace plazza #endif /* !IPIZZA_HPP_ */ diff --git a/src/Pizza/PizzaFactory.cpp b/src/Pizza/PizzaFactory.cpp index 8f07618..5e8c735 100644 --- a/src/Pizza/PizzaFactory.cpp +++ b/src/Pizza/PizzaFactory.cpp @@ -7,44 +7,43 @@ #include "PizzaFactory.hpp" -std::unique_ptr plazza::PizzaFactory::createPizza(PizzaType type, PizzaSize size) -{ - switch (type) - { - case PizzaType::Americana: - return createAmericana(size); - break; - case PizzaType::Fantasia: - return createFantasia(size); - break; - case PizzaType::Margarita: - return createMargarita(size); - break; - case PizzaType::Regina: - return createRegina(size); - break; - default: - return nullptr; - break; - } +std::unique_ptr +plazza::PizzaFactory::createPizza(PizzaType type, PizzaSize size) { + switch (type) { + case PizzaType::Americana: + return createAmericana(size); + break; + case PizzaType::Fantasia: + return createFantasia(size); + break; + case PizzaType::Margarita: + return createMargarita(size); + break; + case PizzaType::Regina: + return createRegina(size); + break; + default: + return nullptr; + break; + } } -std::unique_ptr plazza::PizzaFactory::createAmericana(PizzaSize size) -{ - return std::make_unique(size); +std::unique_ptr +plazza::PizzaFactory::createAmericana(PizzaSize size) { + return std::make_unique(size); } -std::unique_ptr plazza::PizzaFactory::createFantasia(PizzaSize size) -{ - return std::make_unique(size); +std::unique_ptr +plazza::PizzaFactory::createFantasia(PizzaSize size) { + return std::make_unique(size); } -std::unique_ptr plazza::PizzaFactory::createMargarita(PizzaSize size) -{ - return std::make_unique(size); +std::unique_ptr +plazza::PizzaFactory::createMargarita(PizzaSize size) { + return std::make_unique(size); } -std::unique_ptr plazza::PizzaFactory::createRegina(PizzaSize size) -{ - return std::make_unique(size); +std::unique_ptr +plazza::PizzaFactory::createRegina(PizzaSize size) { + return std::make_unique(size); } diff --git a/src/Pizza/PizzaFactory.hpp b/src/Pizza/PizzaFactory.hpp index 61dcd3e..259dc4a 100644 --- a/src/Pizza/PizzaFactory.hpp +++ b/src/Pizza/PizzaFactory.hpp @@ -8,26 +8,25 @@ #ifndef PIZZAFACTORY_HPP_ #define PIZZAFACTORY_HPP_ -#include "IPizza.hpp" #include "Americana.hpp" #include "Fantasia.hpp" +#include "IPizza.hpp" #include "Margarita.hpp" #include "Regina.hpp" -namespace plazza -{ - class PizzaFactory { - public: - - static std::unique_ptr createPizza(PizzaType type, PizzaSize size); +namespace plazza { +class PizzaFactory { +public: + static std::unique_ptr createPizza(PizzaType type, + PizzaSize size); - protected: - private: - static std::unique_ptr createAmericana(PizzaSize size); - static std::unique_ptr createFantasia(PizzaSize size); - static std::unique_ptr createMargarita(PizzaSize size); - static std::unique_ptr createRegina(PizzaSize size); - }; +protected: +private: + static std::unique_ptr createAmericana(PizzaSize size); + static std::unique_ptr createFantasia(PizzaSize size); + static std::unique_ptr createMargarita(PizzaSize size); + static std::unique_ptr createRegina(PizzaSize size); +}; } // namespace plazza #endif /* !PIZZAFACTORY_HPP_ */ diff --git a/src/Pizza/Pizzas/Americana.cpp b/src/Pizza/Pizzas/Americana.cpp index f03b1c1..e565ac0 100644 --- a/src/Pizza/Pizzas/Americana.cpp +++ b/src/Pizza/Pizzas/Americana.cpp @@ -7,12 +7,9 @@ #include "Americana.hpp" -plazza::Americana::Americana(PizzaSize size) : APizza(size) -{ - _size = size; - _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | STEAK); +plazza::Americana::Americana(PizzaSize size) : APizza(size) { + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | STEAK); } -plazza::Americana::~Americana() -{ -} +plazza::Americana::~Americana() {} diff --git a/src/Pizza/Pizzas/Americana.hpp b/src/Pizza/Pizzas/Americana.hpp index b22c100..bd0c304 100644 --- a/src/Pizza/Pizzas/Americana.hpp +++ b/src/Pizza/Pizzas/Americana.hpp @@ -11,13 +11,14 @@ #include "APizza.hpp" namespace plazza { - class Americana : public APizza { - public: - Americana(PizzaSize size); - ~Americana(); - protected: - private: - }; -} +class Americana : public APizza { +public: + Americana(PizzaSize size); + ~Americana(); + +protected: +private: +}; +} // namespace plazza #endif /* !AMERICANA_HPP_ */ diff --git a/src/Pizza/Pizzas/Fantasia.cpp b/src/Pizza/Pizzas/Fantasia.cpp index 6d286fe..56b7fca 100644 --- a/src/Pizza/Pizzas/Fantasia.cpp +++ b/src/Pizza/Pizzas/Fantasia.cpp @@ -1,11 +1,9 @@ #include "Fantasia.hpp" -plazza::Fantasia::Fantasia(PizzaSize size) : APizza(size) -{ - _size = size; - _ingredients = static_cast(DOUGH | TOMATO | EGGPLANT | GOATCHEESE | CHIEFLOVE); +plazza::Fantasia::Fantasia(PizzaSize size) : APizza(size) { + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | EGGPLANT | + GOATCHEESE | CHIEFLOVE); } -plazza::Fantasia::~Fantasia() -{ -} +plazza::Fantasia::~Fantasia() {} diff --git a/src/Pizza/Pizzas/Fantasia.hpp b/src/Pizza/Pizzas/Fantasia.hpp index fc3e56f..04d7154 100644 --- a/src/Pizza/Pizzas/Fantasia.hpp +++ b/src/Pizza/Pizzas/Fantasia.hpp @@ -10,15 +10,15 @@ #include "APizza.hpp" - namespace plazza { - class Fantasia : public APizza { - public: - Fantasia(PizzaSize size); - ~Fantasia(); - protected: - private: - }; -} +class Fantasia : public APizza { +public: + Fantasia(PizzaSize size); + ~Fantasia(); + +protected: +private: +}; +} // namespace plazza #endif /* !FANTASIA_HPP_ */ diff --git a/src/Pizza/Pizzas/Margarita.cpp b/src/Pizza/Pizzas/Margarita.cpp index bfb6f1c..a77127b 100644 --- a/src/Pizza/Pizzas/Margarita.cpp +++ b/src/Pizza/Pizzas/Margarita.cpp @@ -1,11 +1,8 @@ #include "Margarita.hpp" -plazza::Margarita::Margarita(PizzaSize size) : APizza(size) -{ - _size = size; - _ingredients = static_cast(DOUGH | TOMATO | GRUYERE); +plazza::Margarita::Margarita(PizzaSize size) : APizza(size) { + _size = size; + _ingredients = static_cast(DOUGH | TOMATO | GRUYERE); } -plazza::Margarita::~Margarita() -{ -} +plazza::Margarita::~Margarita() {} diff --git a/src/Pizza/Pizzas/Margarita.hpp b/src/Pizza/Pizzas/Margarita.hpp index b4d2584..0a397ea 100644 --- a/src/Pizza/Pizzas/Margarita.hpp +++ b/src/Pizza/Pizzas/Margarita.hpp @@ -10,19 +10,15 @@ #include "APizza.hpp" - -namespace plazza -{ - class Margarita : public APizza { - public: - Margarita(PizzaSize size); - ~Margarita(); - protected: - private: - }; +namespace plazza { +class Margarita : public APizza { +public: + Margarita(PizzaSize size); + ~Margarita(); + +protected: +private: +}; } // namespace plazza - - - #endif /* !MARGARITA_HPP_ */ diff --git a/src/Pizza/Pizzas/Regina.cpp b/src/Pizza/Pizzas/Regina.cpp index ff265c2..dc171c0 100644 --- a/src/Pizza/Pizzas/Regina.cpp +++ b/src/Pizza/Pizzas/Regina.cpp @@ -1,11 +1,9 @@ #include "Regina.hpp" -plazza::Regina::Regina(PizzaSize size) : APizza(size) -{ - _size = size; - _ingredients = static_cast(DOUGH | TOMATO | GRUYERE | HAM | MUSHROOMS); +plazza::Regina::Regina(PizzaSize size) : APizza(size) { + _size = size; + _ingredients = + static_cast(DOUGH | TOMATO | GRUYERE | HAM | MUSHROOMS); } -plazza::Regina::~Regina() -{ -} +plazza::Regina::~Regina() {} diff --git a/src/Pizza/Pizzas/Regina.hpp b/src/Pizza/Pizzas/Regina.hpp index 785756b..24deb4e 100644 --- a/src/Pizza/Pizzas/Regina.hpp +++ b/src/Pizza/Pizzas/Regina.hpp @@ -10,16 +10,15 @@ #include "APizza.hpp" +namespace plazza { +class Regina : public APizza { +public: + Regina(PizzaSize size); + ~Regina(); -namespace plazza -{ - class Regina : public APizza { - public: - Regina(PizzaSize size); - ~Regina(); - protected: - private: - }; +protected: +private: +}; } // namespace plazza #endif /* !REGINA_HPP_ */ diff --git a/src/main.cpp b/src/main.cpp index f55be93..cc7aa89 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,18 +1,21 @@ -#include #include "PizzaFactory.hpp" +#include -int main(void) -{ - std::cout << "The Plazza, the best pizzeria" << std::endl; +int main(void) { + std::cout << "The Plazza, the best pizzeria" << std::endl; - auto americana = plazza::PizzaFactory::createPizza(PizzaType::Americana, PizzaSize::M); + auto americana = + plazza::PizzaFactory::createPizza(PizzaType::Americana, PizzaSize::M); - std::cout << "Americana, size: [" << americana->getSize() << "], ingredients: [" << americana->getIngredients() << "] !" << std::endl; - std::cout << "or..." << std::endl; - std::cout << "Americana, size: [" << americana->getSizeString() << "], ingredients: ["; - std::vector listIngredients = americana->getIngredientsList(); - for (size_t i = 0; i < listIngredients.size(); i++) { - std::cout << listIngredients[i] << ","; - } - std::cout << "] !" << std::endl; + std::cout << "Americana, size: [" << americana->getSize() + << "], ingredients: [" << americana->getIngredients() << "] !" + << std::endl; + std::cout << "or..." << std::endl; + std::cout << "Americana, size: [" << americana->getSizeString() + << "], ingredients: ["; + std::vector listIngredients = americana->getIngredientsList(); + for (size_t i = 0; i < listIngredients.size(); i++) { + std::cout << listIngredients[i] << ","; + } + std::cout << "] !" << std::endl; }