Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine
TRACK

OOP >

CHAPTER

Factory Pattern

Next Chapter

Challenge #2 of 2


Q: 

What is the downside of using multiple make methods, like in the example below:

class WeaponFactory
{
    public function makeSword(): WeaponInterface
    {
        return new Sword(Dice::rollRange(4, 8), 12);
    }

    public function makeAxe(int $bonusDamage = 0): WeaponInterface
    {
        return new Axe($bonusDamage + Dice::rollRange(6, 12), 8);
    }
}

userVoice