Assuming I have an object with 2 mode, each mode has its corresponding actions:
Mode 1:
-
Do1()
-
Do2()
Mode 2:
-
Do1()
-
Do2()
-
Do3()
Note: Do1() and Do2() of Mode 1 and Mode 2 are the similar.
I thought of the state and strategy pattern, but they were not appropriate in this case. This case, no need virtual methods, just inherit. But how to change the mode, it will understand the corresponding method?
Which design pattern is appropriate in this case?
Aucun commentaire:
Enregistrer un commentaire