I am now studying the concept of OOD and I have created a program for a pizza shop. The base class here is pizza. I want to put a spicy characteristic for pizza as an interface, but I find a problem in the actual application. Here is the code. How can I combine making pizza with it being spicy?
how i can make beef spicy pizza object [how can i make pizza and make it spicy via interface]
how to use interface here.
#include <iostream>
#include <string>
using namespace std;
// base-class
class Pizza
{
private:
void MakeDough()
{
cout << "Make " << getPizzaType() << " Pizza Dough is Done.." << endl;
}
void Bake()
{
cout << "Bake " << getPizzaType() << " Pizza is Done.." << endl;
}
void AddToppings()
{
cout << "Adding " << PizzaToppings() << " is Done.." << endl;
}
protected:
virtual string getPizzaType() = 0;
virtual string PizzaToppings() = 0;
public:
void MakePizza()
{
MakeDough();
AddToppings();
Bake();
cout << "======================================\n";
cout << getPizzaType() << " Pizza is Done..\n" << endl;
}
};
//interface
class Spicy
{
public:
virtual void makePizzaSpicy() = 0;
};
class BeefPizza : public Pizza, public Spicy
{
protected:
// from Pizza Class
virtual string getPizzaType()
{
return "Beef";
}
virtual string PizzaToppings()
{
return "Beef Pizza Toppings";
}
public:
// from spicy class
virtual void makePizzaSpicy()
{
// code
}
};
class ChickenPizza : public Pizza
{
protected:
virtual string getPizzaType()
{
return "Chicken";
}
virtual string PizzaToppings()
{
return "Chicken Pizza Toppings";
}
};
class MakingPizza
{
public:
void MakePizza(Pizza* pizza)
{
pizza->MakePizza();
}
};
int main()
{
// here how i can make beef spicy pizza object
}