vendredi 28 juillet 2017

State pattern for FSM

I want to create FSM, which have 4 states, like this: http://ift.tt/2w6jYNZ

I think to use State pattern, but I can't figure out how to set all this transferring. Maybe I should use another one? How I made it for now:

public class Driver {
public static void main(String[] args) {

    Context context = new Context();
    State AAAllocked = new StateAAAllLocked();
    State ADAllocked = new StateADAllLocked();
    State ADAllUnlocked = new StateADAllUnlocked();
    State ADDriverUnlocked = new StateADDriverUnlocked();

    context.setState(ADAllUnlocked);

    context.doAction();

}

I have these 4 states and can choose which action do. But how make it like on the picture?

Aucun commentaire:

Enregistrer un commentaire