Suppose there are four states like below.
A state
B state
C state
D state
And there is a complex transition dependency like below.
A is default state
B is C,D state's precondition
C is D state's precondition
Currently, my idea is the following.
if(conditionXXX){
state = B;
}
else if(B && conditionYYY) {
state = C;
}
else if(C && conditionZZZ) {
state = D;
}
else {
state = A;
}
But I'm considering that is not a nice solution. Is there any good design pattern or a good solution?
Aucun commentaire:
Enregistrer un commentaire