Answer the question
In order to leave comments, you need to log in
String validation through the Stateless Framework. How to implement?
Hello! I wrote a DFA model program using the stateless framework, the entered string after a character-by-character check should remain in its initial state. I can't figure out how to link a string and a DFA model. For example, you can take a string whose elements will go through the entire model and remain in q0
string isValue = "11010";
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Stateless;
using Stateless.Graph;
namespace Lib1
{
enum State
{
Q0,
Q1,
Q2
}
enum Input
{
One = 1,
Zero = 0
}
class Program
{
static void Main(string[] args)
{
string isValue = "11010";
var stateMachine = new StateMachine<State, Input>(State.Q0);
stateMachine.Configure(State.Q0)
.Permit(Input.Zero, State.Q2)
.PermitReentry(Input.One);
stateMachine.Configure(State.Q1)
.Permit(Input.Zero, State.Q0)
.PermitReentry(Input.One);
stateMachine.Configure(State.Q2)
.Permit(Input.One, State.Q1)
.PermitReentry(Input.Zero);
// stateMachine.Fire(Input.Zero);
string graph = UmlDotGraph.Format(stateMachine.GetInfo());
Console.WriteLine(graph);
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question