I have an Action class, where an Action can do a range of things, including:
- Performing a sequential list of other actions
- Performing an action if a condition is true
- Allowing the user to pick between several different actions.
The last case that I mentioned is the tricky one. The project I am working is GUI based, and the main loop is not in my control. Hence, I need some way to tell the UI "offer the user a choice". There are two ways I've considered doing this:
act()function set some variable in the UI, then return. This makes Action #1 listed above difficult to implement (as it shouldn't increment to the next action). I may also have
act()return true/false to determine whether or not it is finished, or include a
Have the Action class have a
getNextActions()function that returns a
List<Action>. If the list only has one element, it'll perform that one, otherwise give the user a list of choices.
I think both of these feel feasible, but I'm unsure which would be the best in terms of maintainability and code flexibility. Which option would be the best, or is there a 3rd option I haven't thought of?