static void Main(string[] args) { Process p = new Process(); Console.WriteLine("Current State = " + p.CurrentState); Console.WriteLine("Command.Begin: Current State = " + p.MoveNext(Command.Begin)); Console.WriteLine("Command.Pause: Current State = " + p.MoveNext(Command.Pause)); Console.WriteLine("Command.End: Current State = " + p.MoveNext(Command.End)); Console.WriteLine("Command.Exit: Current State = " + p.MoveNext(Command.Exit)); }
static void Main(string[] args) { string userResponse = ""; List <Command> commands = new List <Command>(); Console.WriteLine("Welcome to Simplistic TCP Finite State Machine program."); Console.WriteLine("Please enter each event that you want to evaluate individually and press Enter."); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Anytime enter Q or q to finish your capture."); while (userResponse.ToLower() != "q") { userResponse = Console.ReadLine(); if (userResponse.ToLower() == "q") { break; } try { Command providedCommand = (Command)Enum.Parse(typeof(Command), userResponse, true); if (Enum.IsDefined(typeof(Command), providedCommand) | providedCommand.ToString().Contains(",")) { commands.Add(providedCommand); } else { Console.WriteLine("{0} is not an underlying value of the TCP Events enumeration.", providedCommand.ToString()); } } catch (ArgumentException) { Console.WriteLine("{0} is not a member of the TCP Events enumeration.", userResponse); } } try { Process p = new Process(); ProcessState nextState = new ProcessState(); foreach (Command command in commands) { nextState = p.MoveNext(command); } PrintProgramFinalization(p.CurrentState.ToString()); } catch { PrintProgramFinalization("ERROR"); } }
static void Main(string[] args) { Process p = new Process(); Console.WriteLine("Current State = " + p.CurrentState); Console.WriteLine("Command.Begin: Current State = " + p.MoveNext(Command.Begin)); Console.WriteLine("Command.Pause: Current State = " + p.MoveNext(Command.Pause)); Console.WriteLine("Command.End: Current State = " + p.MoveNext(Command.End)); Console.WriteLine("Command.Exit: Current State = " + p.MoveNext(Command.Exit)); Console.WriteLine("\nNew set of input"); Console.WriteLine("Current State = " + p.CurrentState); Console.WriteLine("Command.Begin: Current State = " + p.MoveNext(Command.End)); Console.WriteLine("Command.Pause: Current State = " + p.MoveNext(Command.Pause)); Console.WriteLine("Command.End: Current State = " + p.MoveNext(Command.Begin)); Console.WriteLine("Command.Exit: Current State = " + p.MoveNext(Command.Exit)); Console.WriteLine("\nNew set of input"); Console.WriteLine("Command.Begin: Current State = " + p.MoveNext(Command.Begin)); Console.WriteLine("Command.Pause: Current State = " + p.MoveNext(Command.Pause)); Console.WriteLine("Command.Pause: Current State = " + p.MoveNext(Command.Resume)); Console.WriteLine("Command.End: Current State = " + p.MoveNext(Command.End)); Console.WriteLine("Command.Exit: Current State = " + p.MoveNext(Command.Exit)); Console.ReadKey(); }