augment the factory pattern in java

前端 未结 3 844
Happy的楠姐
Happy的楠姐 2021-02-04 19:48

I am trying to use a factory pattern to create a QuestionTypeFactory where the instantiated classes will be like MultipleChoice, TrueFalseQuestion etc.

The factory code

3条回答
  •  被撕碎了的回忆
    2021-02-04 20:15

    I'm pretty sure you just want to create a method on your enum type which will return the appropriate Question object. So anytime someone adds an enum value to QuestionType they will also have to update the method. Doesn't solve your problem of having to update that method though...

提交回复
热议问题