This repository has been archived on 2022-11-09. You can view files and clone it, but cannot push or open issues or pull requests.
patterns-old/lesson_4/NYPizzaStore.hpp

55 lines
1.4 KiB
C++
Raw Normal View History

2021-11-02 18:18:09 +00:00
/*
* NYPizzaStore.hpp
*
2021-11-03 15:35:58 +00:00
* Created on: 3 нояб. 2021 г.
2021-11-02 18:18:09 +00:00
* Author: alexander
*/
#pragma once
#include "PizzaStore.hpp"
2021-11-03 15:35:58 +00:00
#include "CheesePizza.hpp"
#include "PepperoniPizza.hpp"
#include "VeggiePizza.hpp"
#include "ClamPizza.hpp"
#include "StandardPizza.hpp"
#include "NYPizzaIngredientFactory.hpp"
2021-11-02 18:18:09 +00:00
class NYPizzaStore: public PizzaStore
{
public:
2021-11-03 15:35:58 +00:00
Pizza* createPizza(const std::string &type) const override
2021-11-02 18:18:09 +00:00
{
2021-11-03 15:35:58 +00:00
Pizza *pizza = NULL;
PizzaIngredientFactory *ingredientFactory = new NYPizzaIngredientFactory();
2021-11-02 18:18:09 +00:00
if (type == "cheese")
{
2021-11-03 15:35:58 +00:00
pizza = new CheesePizza(ingredientFactory);
pizza->setName("New York Style Cheese Pizza");
2021-11-02 18:18:09 +00:00
}
else if (type == "veggie")
{
2021-11-03 15:35:58 +00:00
pizza = new VeggiePizza(ingredientFactory);
pizza->setName("New York Style Veggie Pizza");
2021-11-02 18:18:09 +00:00
}
else if (type == "clam")
{
2021-11-03 15:35:58 +00:00
pizza = new ClamPizza(ingredientFactory);
pizza->setName("New York Style Clam Pizza");
2021-11-02 18:18:09 +00:00
}
else if (type == "pepperoni")
{
2021-11-03 15:35:58 +00:00
pizza = new PepperoniPizza(ingredientFactory);
pizza->setName("New York Style Pepperoni Pizza");
2021-11-02 18:18:09 +00:00
}
else
{
2021-11-03 15:35:58 +00:00
pizza = new StandardPizza(ingredientFactory);
pizza->setName("New York Style Standard Pizza");
2021-11-02 18:18:09 +00:00
}
2021-11-03 15:35:58 +00:00
return pizza;
2021-11-02 18:18:09 +00:00
}
};