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.
分享到:
相关推荐
安装JAVA VTK以及运行VTK EXAMPLES的指导,使用jdk5,vtk4.4.2
This examples explores hierarchichal state machines using an example of a hardware unit that can be in the following states: •Inservice state ◦Active state ◦Standby state •Out_Of_Service ◦...
Inside the Java Virtual Machine Bill Venners $39.95 0-07-913248-0 Inside the Java Virtual Machine Acknowledgments Introduction Part One: Java's Architecture 1 Introduction to Java's Architecture Why ...
Finite State Machine Datapath Design, Optimization, and Implementation explores the design space of combined FSM/Datapath implementations. The lecture starts by examining performance issues in digital...
1.Review on counter design 2.State Diagrams for FSM 3.Moore & Mealy Models 4.State Minimization 5.Examples 6.HDL for FSMV
Mastering Java Machine Learning ...A practical guide to help you explore machine learning―and an array of Java-based tools and frameworks―with the help of practical examples and real-world use cases.
on java 8(Thinking in java 5e) 源代码
Java Examples in a Nutshell
Java 8 Book - Examples , Java8 Examples
这份java示例文件涵盖java标准库中类,每个类都有一个示例。很好的展示了,每个类中各方法的用法,是java学习者的好材料。
一大堆java基础类的小例子 java.applet [8 examples] java.awt [78 examples] java.awt.datatransfer [3 examples] java.awt.dnd [3 examples] java.awt.event [8 examples] java.awt.font ...
java-linq-examples 是 101 个 LINQ 示例的 Java 移植版本。Android 兼容 Java 1.7.此外还有以下语言移植版本:SwiftClojureDart
Java Examples in a Nutshell(3rd) 英文epub 第3版 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源转载自网络,如有侵权,请联系上传者或csdn删除
Java for Programmers 2nd Edition 範例程式
java rest ful examples code for chat 2
Java Cryptography with Examples 运用Jave软件包实现加密算法
OnJava8-Examples-master
Java EE 7 tutorial 中的examples代码,找了很久才找到下来的,跟Java EE 7 tutorial配套使用,是官方的学习资料。