Results 1 to 2 of 2
- 04-24-2014, 09:10 PM #1
Member
- Join Date
- Mar 2014
- Posts
- 6
- Rep Power
- 0
Would this be a Finite State Machine?
Say I have this code.
Java Code:public interface State { void processOne(); void processTwo(); void processThree(); } public class AStateImplOne implements State { @Override public void processOne() { doStuff(); } @Override public void processTwo() { doStuff(); } @Override public void processThree() { doStuff(); } private void doStuff() {} } public class AStateImplTwo implements State { @Override public void processOne() { doStuff(); } @Override public void processTwo() { doStuff(); } @Override public void processThree() { doStuff(); } private void doStuff() {} } public class StateMachine { private State one = new AStateImplOne(); private State two = new AStateImplTwo(); private State state; public int loop() { checkState(); state.processOne(); state.processTwo(); state.processThree(); return 0; } private void checkState() { if (condition) { state = one; } else { state = two; } } }
Last edited by TheRealInjustice; 04-24-2014 at 09:17 PM.
- 04-24-2014, 09:44 PM #2
Senior Member
- Join Date
- Jan 2013
- Location
- Northern Virginia, United States
- Posts
- 6,226
- Rep Power
- 15
Re: Would this be a Finite State Machine?
A finite state machine basically goes from one state to another based on the current state. Which means there must be some change for the driver to switch states.
In your case, it looks like the state machine is doing the same stuff from each process.
Regards,
JimLast edited by jim829; 04-24-2014 at 09:48 PM.
The JavaTM Tutorials | SSCCE | Java Naming Conventions
Poor planning on your part does not constitute an emergency on my part
Similar Threads
-
State machine pattern in games
By noodle_variation_187-X in forum Java GamingReplies: 2Last Post: 04-10-2013, 04:10 PM -
How to release multiple threads from waiting state to runnable state
By Dayanand in forum New To JavaReplies: 2Last Post: 02-14-2011, 02:27 PM -
Help needed to create an Automata state machine in Java
By maz09 in forum New To JavaReplies: 6Last Post: 02-05-2010, 04:53 PM -
I have problem in parsing state machine diagram
By Saniya in forum EclipseReplies: 0Last Post: 06-10-2008, 07:37 AM -
Concurrent Hierarchical State Machine 4.3
By levent in forum Java SoftwareReplies: 0Last Post: 08-03-2007, 04:44 PM
Bookmarks