module abstractfactory.pizza;

import abstractfactory.dough;
import abstractfactory.sauce;
import abstractfactory.veggies;
import abstractfactory.cheese;
import abstractfactory.pepperoni;
import abstractfactory.clams;
import std.stdio : writeln;
import std.conv : to;

abstract class Pizza
{
protected:
    string name;
    Dough dough;
    Sauce sauce;
    Veggies[] veggies;
    Cheese cheese;
    Pepperoni pepperoni;
    Clams clams;
public:
    void prepare();

    void bake()
    {
        writeln("Bake for 25 minutes at 350");
    }

    void cut()
    {
        writeln("Cut the pizza into diagonal slices");
    }

    void box()
    {
        writeln("Place pizza in official PizzaStore box");
    }

    void setName(string name)
    {
        this.name = name;
    }

    string getName()
    {
        return name;
    }

    override string toString() const
    {
        string s;
        s ~= "---- " ~ name ~ " ----\n";
        if (dough !is null)
        {
            s ~= dough ~ "\n";
        }
        if (sauce !is null)
        {
            s ~= sauce ~ "\n";
        }
        if (cheese !is null)
        {
            s ~= cheese ~ "\n";
        }
        if (veggies.length)
        {
            foreach (key, val; veggies)
            {
                s ~= val.to!string;
                if (key + 1 < veggies.length)
                {
                    s ~= ", ";
                }
            }
        }
        if (clams !is null)
        {
            s ~= clams ~ "\n";
        }
        if (pepperoni !is null)
        {
            s ~= pepperoni ~ "\n";
        }

        return s;
    }
}
