Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
plazza
.build
clang++
.vscode
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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

Expand Down
32 changes: 32 additions & 0 deletions src/Pizza/APizza.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
** 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<std::string> plazza::APizza::getIngredientsList() const {
std::vector<std::string> listIngredients;

for (uint16_t bit = 1; bit <= CHIEFLOVE; bit <<= 1) {
if (_ingredients & bit) {
listIngredients.push_back(
ingredientsToString[static_cast<Ingredients>(bit)]);
}
}
return listIngredients;
}
33 changes: 33 additions & 0 deletions src/Pizza/APizza.hpp
Original file line number Diff line number Diff line change
@@ -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<std::string> getIngredientsList() const override;

protected:
PizzaSize _size;
Ingredients _ingredients;

private:
};
} // namespace plazza

#endif /* !APIZZA_HPP_ */
65 changes: 65 additions & 0 deletions src/Pizza/IPizza.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** IPizza
*/

#ifndef IPIZZA_HPP_
#define IPIZZA_HPP_

#include <cstdint>
#include <iomanip>
#include <map>
#include <memory>
#include <vector>

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 };

static inline std::map<PizzaSize, std::string> sizeToString = {
{PizzaSize::S, "S"},
{PizzaSize::M, "M"},
{PizzaSize::L, "L"},
{PizzaSize::XL, "XL"},
{PizzaSize::XXL, "XXL"}};

static inline std::map<Ingredients, std::string> 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){};
virtual ~IPizza() = default;

virtual PizzaSize getSize() const = 0;
virtual std::string getSizeString() const = 0;

virtual Ingredients getIngredients() const = 0;
virtual std::vector<std::string> getIngredientsList() const = 0;

protected:
private:
};
} // namespace plazza

#endif /* !IPIZZA_HPP_ */
49 changes: 49 additions & 0 deletions src/Pizza/PizzaFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** PizzaFactory
*/

#include "PizzaFactory.hpp"

std::unique_ptr<plazza::IPizza>
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::IPizza>
plazza::PizzaFactory::createAmericana(PizzaSize size) {
return std::make_unique<plazza::Americana>(size);
}

std::unique_ptr<plazza::IPizza>
plazza::PizzaFactory::createFantasia(PizzaSize size) {
return std::make_unique<plazza::Fantasia>(size);
}

std::unique_ptr<plazza::IPizza>
plazza::PizzaFactory::createMargarita(PizzaSize size) {
return std::make_unique<plazza::Margarita>(size);
}

std::unique_ptr<plazza::IPizza>
plazza::PizzaFactory::createRegina(PizzaSize size) {
return std::make_unique<plazza::Regina>(size);
}
32 changes: 32 additions & 0 deletions src/Pizza/PizzaFactory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** PizzaFactory
*/

#ifndef PIZZAFACTORY_HPP_
#define PIZZAFACTORY_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<plazza::IPizza> createPizza(PizzaType type,
PizzaSize size);

protected:
private:
static std::unique_ptr<plazza::IPizza> createAmericana(PizzaSize size);
static std::unique_ptr<plazza::IPizza> createFantasia(PizzaSize size);
static std::unique_ptr<plazza::IPizza> createMargarita(PizzaSize size);
static std::unique_ptr<plazza::IPizza> createRegina(PizzaSize size);
};
} // namespace plazza

#endif /* !PIZZAFACTORY_HPP_ */
15 changes: 15 additions & 0 deletions src/Pizza/Pizzas/Americana.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** Americana
*/

#include "Americana.hpp"

plazza::Americana::Americana(PizzaSize size) : APizza(size) {
_size = size;
_ingredients = static_cast<Ingredients>(DOUGH | TOMATO | GRUYERE | STEAK);
}

plazza::Americana::~Americana() {}
24 changes: 24 additions & 0 deletions src/Pizza/Pizzas/Americana.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** Americana
*/

#ifndef AMERICANA_HPP_
#define AMERICANA_HPP_

#include "APizza.hpp"

namespace plazza {
class Americana : public APizza {
public:
Americana(PizzaSize size);
~Americana();

protected:
private:
};
} // namespace plazza

#endif /* !AMERICANA_HPP_ */
9 changes: 9 additions & 0 deletions src/Pizza/Pizzas/Fantasia.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Fantasia.hpp"

plazza::Fantasia::Fantasia(PizzaSize size) : APizza(size) {
_size = size;
_ingredients = static_cast<Ingredients>(DOUGH | TOMATO | EGGPLANT |
GOATCHEESE | CHIEFLOVE);
}

plazza::Fantasia::~Fantasia() {}
24 changes: 24 additions & 0 deletions src/Pizza/Pizzas/Fantasia.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** Fantasia
*/

#ifndef FANTASIA_HPP_
#define FANTASIA_HPP_

#include "APizza.hpp"

namespace plazza {
class Fantasia : public APizza {
public:
Fantasia(PizzaSize size);
~Fantasia();

protected:
private:
};
} // namespace plazza

#endif /* !FANTASIA_HPP_ */
8 changes: 8 additions & 0 deletions src/Pizza/Pizzas/Margarita.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include "Margarita.hpp"

plazza::Margarita::Margarita(PizzaSize size) : APizza(size) {
_size = size;
_ingredients = static_cast<Ingredients>(DOUGH | TOMATO | GRUYERE);
}

plazza::Margarita::~Margarita() {}
24 changes: 24 additions & 0 deletions src/Pizza/Pizzas/Margarita.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** Margarita
*/

#ifndef MARGARITA_HPP_
#define MARGARITA_HPP_

#include "APizza.hpp"

namespace plazza {
class Margarita : public APizza {
public:
Margarita(PizzaSize size);
~Margarita();

protected:
private:
};
} // namespace plazza

#endif /* !MARGARITA_HPP_ */
9 changes: 9 additions & 0 deletions src/Pizza/Pizzas/Regina.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "Regina.hpp"

plazza::Regina::Regina(PizzaSize size) : APizza(size) {
_size = size;
_ingredients =
static_cast<Ingredients>(DOUGH | TOMATO | GRUYERE | HAM | MUSHROOMS);
}

plazza::Regina::~Regina() {}
24 changes: 24 additions & 0 deletions src/Pizza/Pizzas/Regina.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** EPITECH PROJECT, 2026
** plazza
** File description:
** Regina
*/

#ifndef REGINA_HPP_
#define REGINA_HPP_

#include "APizza.hpp"

namespace plazza {
class Regina : public APizza {
public:
Regina(PizzaSize size);
~Regina();

protected:
private:
};
} // namespace plazza

#endif /* !REGINA_HPP_ */
Loading