Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7196137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:43:14+00:00 2026-05-28T20:43:14+00:00

// Abstract factory class class pizzaStore { public: vector <string> toppingsType; virtual void bakePizza

  • 0

// Abstract factory class

class pizzaStore
{
     public:
      vector <string> toppingsType;

      virtual void bakePizza        (){}
      virtual void preparePizza     ()
      {
           for (int i = 0; i < toppingsType.size (); i++)
           {
            addTopping (toppingsType[i]);
           }
      }

      virtual void cutPizza         (){}
      virtual void boxPizza     (){}
};

class xPizzaStore : public pizzaStore
{
     xPizzaStore () 
     {
      toppingsType = "1";
      sauceType      = "2";
      cheesetype     = "3";
     }

     void orderPizza ()
     {
      bakePizza ();
      preparePizza ();
      // xPizzaStore doesn't cut the pizza.
      boxPizza ();
     }
};

// Factory method for creating stores

pizzaStore * whichStore (string storeName)
{
      pizzaStore obj = NULL;

      if (storeName == "x")
      {
           obj = new xPizzaStore ();
      }
      else if (storeName == "y")
      {
           obj = new yPizzaStore ();
      }
      else if (storeName == "z")
      {
           obj = new zPizzaStore ();
      }

      return obj;
}

// Factory method for creating pizzas

pizzaStore * whichPizza (string pizzaName)
{
      pizzaName obj = NULL;

      if (pizzaBaseType == "x")
      {
           obj = new xPizzaName ();
      }
      else if (pizzaBaseType == "y")
      {
           obj = new yPizzaName ();
      }
      else if (pizzaBaseType == "z")
      {
           obj = new zPizzaName ();
      }

      return obj;
}

There can be different types of stores as well as pizzas.
In which class should these two factory methods be included and why?
Does it make sense to include them in the pizzaStore class itself?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T20:43:16+00:00Added an answer on May 28, 2026 at 8:43 pm

    Does it make sense to include them in the pizzaStore class itself?

    Yes, it should be perfectly fine to put those method in class pizzaStore as static methods. Generally I consider, putting such factory method in a class based on its return type, and pizzaStore is a good candidate for it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following abstract factory: #include MediaDevice.h class MediaFactory { public: MediaFactory(); virtual ~MediaFactory();
Given a abstract factory implementation: public class FooFactory : IFooFactory { public IFoo Create(object
I've implemented an abstract factory like this public abstract class AbstractFactory { private static
I am defining a static factory method with: @XmlType(factoryClass=DummyFactory.class, factoryMethod=createNew) public abstract MyClass() {
In my console application have an abstract Factory class Listener which contains code for
I have a class with a factory-pattern function in it: abstract class ParentObj {
abstract class base { abstract public function test(); public function run() { self::test(); }
Let's say I have a Java class abstract class Base { abstract void init();
I have a generic abstract class Factory<T> with a method createBoxedInstance() which returns instances
Currently, I use an abstract factory to allow the specification of a custom class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.