Java的StateMachine(二)More Examples
Java的StateMachine(二)More Examples
首頁
http://smc.sourceforge.net/
圖形化工具
http://www.graphviz.org/
I download the Smc version 6.0.1.
we just have the examples of java one by one
EXAMPLE 1
AppClass.sm is just what the example like, I never change it, it seems that it stands for the 00011110000 things.
AppClass.java I add some comments on the key point :
_fsm.setDebugFlag(true);
I set the debug on to see the logs.
I think the most import part is here:
public void Acceptable() {
// here is the real action we want to write in App, and it will be
// called by AppClassContext
_is_acceptable = true;
}
And I make a little test file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0001111";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0001111" is
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.OK
acceptable.
EXAMPLE 2
We add a new Default transaction.
EXAMPLE 3
This state machine "recognizes" the palindromes (words that read the same backwards as forwards). The words consist of the alphabet {0, 1, c} where the letter 'c' may appear only once and marks the words center.
I make a test java file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0c0";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0c0" is
PUSH TO STATE : ZerosMap.PushIt
ENTER STATE : ZerosMap.PopIt
POP TO STATE : StartMap.PushIt
ENTER STATE : StartMap.PopIt
ENTER STATE : StartMap.Acceptable
acceptable.
EXAMPLE 7
this example stands for the telephones.
After all the work, I found that our project use the version 4.3, so there must be some small differences.
首頁
http://smc.sourceforge.net/
圖形化工具
http://www.graphviz.org/
I download the Smc version 6.0.1.
we just have the examples of java one by one
EXAMPLE 1
AppClass.sm is just what the example like, I never change it, it seems that it stands for the 00011110000 things.
AppClass.java I add some comments on the key point :
_fsm.setDebugFlag(true);
I set the debug on to see the logs.
I think the most import part is here:
public void Acceptable() {
// here is the real action we want to write in App, and it will be
// called by AppClassContext
_is_acceptable = true;
}
And I make a little test file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0001111";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0001111" is
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Zeros
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.Ones
ENTER STATE : Map1.OK
acceptable.
EXAMPLE 2
We add a new Default transaction.
EXAMPLE 3
This state machine "recognizes" the palindromes (words that read the same backwards as forwards). The words consist of the alphabet {0, 1, c} where the letter 'c' may appear only once and marks the words center.
I make a test java file AppClassTest.java:
package com.sillycat.sm.appclass;
public class AppClassTest {
public static void main(String[] args) {
String str = "0c0";
AppClass appobject = new AppClass();
System.out.print("The string \"");
System.out.print(str);
System.out.print("\" is ");
if (appobject.CheckString(str) == false) {
System.out.println("not acceptable.");
} else {
System.out.println("acceptable.");
}
}
}
And we get the output like this:
The string "0c0" is
PUSH TO STATE : ZerosMap.PushIt
ENTER STATE : ZerosMap.PopIt
POP TO STATE : StartMap.PushIt
ENTER STATE : StartMap.PopIt
ENTER STATE : StartMap.Acceptable
acceptable.
EXAMPLE 7
this example stands for the telephones.
After all the work, I found that our project use the version 4.3, so there must be some small differences.
相關文章
- Java的StateMachine(一)說明文件JavaMac
- java-string-tutorial-and-examples-beginners-programmingJava
- simd examples
- crewAI-examplesAI
- examples for oracle ref cursorsOracle
- gitglossary learning by examplesGit
- DBMS_REPAIR ExamplesAI
- Examples of Secondary IndexIndex
- [Android] 狀態機 StateMachine 原始碼剖析AndroidMac原始碼
- Ten examples of git-archiveGitHive
- MapInfo is no moreAPI
- Spring Boot 2.x實戰之StateMachineSpring BootMac
- "bare repository" learning by examples
- Spark2.0.0 Install And ExamplesSpark
- java.sql.SQLException: The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents moreJavaSQLExceptionServerZed
- completablefuture-examples:Java 20個CompletableFuture API案例程式碼片段JavaAPI
- Do more, fasterAST
- java.io.IOException: Error opening job jar: hadoop-0.20.2-examples.jarJavaExceptionErrorJARHadoop
- Oracle Reporting 7 - Model ExamplesOracle
- The Art of Unit Testing: with examples in C#C#
- Some examples of using these views follow.View
- airflow DAG/PIPELINE examples referenceAI
- Regular Expressions in Grep Command with 10 Examples --referenceExpress
- Linux Crontab:15 Awesome Cron Job ExamplesLinux
- TypeScript 之 More on FunctionsTypeScriptFunction
- MORE_DETAIL_TECHAI
- 15 Practical Grep Command Examples In Linux / UNIXLinux
- 10 Awesome Examples for Viewing Huge Log Files in UnixView
- zero-shot-learning-definition-examples-comparison
- DNS: More than just namesDNS
- 04 - More about CSS PositionCSS
- Allocate More Space for a Database (37)Database
- cat ,more ,less 命令的使用和差別
- HowTo: The Ultimate Logrotate Command Tutorial with 10 Exampleslogrotate
- 12 Bash For Loop Examples for Your Linux Shell ScriptingOOPLinux
- MassTransit | 基於StateMachine實現Saga編排式分散式事務Mac分散式
- Linux基礎命令---moreLinux
- Linux more命令詳解Linux