mardi 12 octobre 2021

Use Factory pattern

I try to use Factory pattern in this code. I have a method that take three arguments as input and I need to return a factory that creates a classic Disney plot. Do I apply the given pattern correctly? And how return a factory that creates a classic Disney plot?

public PlotFactory classicDisneyPlotFactory(Character hero, Character another, Character without) {
        if (hero.equals("A") && another.equals("B") && without.equals("C")){
           return  .....;
        } else if (hero.equals("D") && another.equals("E")&& without.equals("F")){
            return ....;
        }else if (hero.equals("G") && another.equals("H")&& without.equals("I")){
            return ....;
        }
        
    }

Aucun commentaire:

Enregistrer un commentaire