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.
相關文章
- VirtualHost Examples
- simd examples
- crewAI-examplesAI
- gitglossary learning by examplesGit
- [Android] 狀態機 StateMachine 原始碼剖析AndroidMac原始碼
- examples for oracle ref cursorsOracle
- "bare repository" learning by examples
- completablefuture-examples:Java 20個CompletableFuture API案例程式碼片段JavaAPI
- Spring Boot 2.x實戰之StateMachineSpring BootMac
- airflow DAG/PIPELINE examples referenceAI
- Ten examples of git-archiveGitHive
- java.sql.SQLException: The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents moreJavaSQLExceptionServerZed
- zero-shot-learning-definition-examples-comparison
- MORE_DETAIL_TECHAI
- TypeScript 之 More on FunctionsTypeScriptFunction
- More web function requests go online concurrently, and web service deployment is faster and more economical!WebFunctionGoAST
- cannot find trajectory file at ./examples/trajectory.txt
- 【Basic Abstract Algebra】Exercises for Section 2.1 — Definitions and examples
- DNS: More than just namesDNS
- Linux基礎命令---moreLinux
- B-A Bit More Common
- Vegetables need more practice.
- Compare two or more repo directories
- LIFE2020-make-more
- MassTransit | 基於StateMachine實現Saga編排式分散式事務Mac分散式
- Linux常用基本命令(more)Linux
- E. We Need More Bosses
- 構建帶headers-more-nginx-module的nginxHeaderNginx
- basictracer-go原始碼閱讀——examples(完結)Go原始碼
- MIT6.S081 - Lecture1: Introduction and ExamplesMIT
- Java新增構造方法異常異常——Could not autowire. there is more than one bean of '' typeJava構造方法Bean
- 常用命令---less---more
- HDU 6033 Add More Zero (數學)
- Linux下more命令高階用法Linux
- A way to represent that more realistically might be forcing users
- 【等待事件】SQL*Net more data to client事件SQLclient
- Linux中less和more命令的區別有哪些?Linux
- v2.5.4,changelog:add examples in json schema 例子沒找到JSON
- 學習Java的第二週Java