public static void Main(string[] args) { bool isDone = false; while (!isDone) { Console.WriteLine("Note: Each word entered must end with a character " + "that does not appear earlier in the word."); List <string> words = new List <string>(); for (int wordNum = 0; ; wordNum++) { Console.Write(String.Format("Enter word #{0:d}{1:s}: ", wordNum, wordNum == 0 ? " (with a unique terminating character) " : " (enter an empty string to end input) " )); Console.Out.Flush(); string word = Console.ReadLine(); if (word == null || word.Length == 0) { break; } else { words.Add(word); } } GSuffixTree.Verbosity = GstVerbosityLevel.Verbose; GSuffixTree tree = null; bool isCreationSuccessful = false; try { tree = new GSuffixTree(words, true); Console.WriteLine("Final suffix tree:"); Console.WriteLine(tree.ToString()); } catch (Exception ex) { isCreationSuccessful = false; Console.WriteLine(); Console.WriteLine(String.Format( "Suffix tree creation: Caught exception: {0:s}", ex.Message)); Console.WriteLine("Note: This program is currently a work in progress."); } Console.WriteLine(); if (isCreationSuccessful) { Console.Write("Press 'Enter' to proceed with validation: "); Console.Out.Flush(); Console.ReadLine(); try { runTests(tree); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(String.Format( "Suffix tree testing: Caught exception: {0;s}", ex.Message)); Console.WriteLine("Note: This program is currently a work in progress."); } } Console.Write("Continue (y or n)? "); Console.Out.Flush(); string continueStr = Console.ReadLine(); if (continueStr == null || continueStr.Length > 0 && continueStr.ToLower()[0] != 'y') { isDone = true; } } }
public static void Main(string[] args) { bool isDone = false; while (!isDone) { Console.WriteLine("Note: Each word entered must end with a character " + "that does not appear earlier in the word."); List<string> words = new List<string>(); for (int wordNum = 0; ; wordNum++) { Console.Write(String.Format("Enter word #{0:d}{1:s}: ", wordNum, wordNum == 0 ? " (with a unique terminating character) " : " (enter an empty string to end input) " )); Console.Out.Flush(); string word = Console.ReadLine(); if (word == null || word.Length == 0) { break; } else { words.Add(word); } } GSuffixTree.Verbosity = GstVerbosityLevel.Verbose; GSuffixTree tree = null; bool isCreationSuccessful = false; try { tree = new GSuffixTree(words, true); Console.WriteLine("Final suffix tree:"); Console.WriteLine(tree.ToString()); } catch (Exception ex) { isCreationSuccessful = false; Console.WriteLine(); Console.WriteLine(String.Format( "Suffix tree creation: Caught exception: {0:s}", ex.Message)); Console.WriteLine("Note: This program is currently a work in progress."); } Console.WriteLine(); if (isCreationSuccessful) { Console.Write("Press 'Enter' to proceed with validation: "); Console.Out.Flush(); Console.ReadLine(); try { runTests(tree); } catch (Exception ex) { Console.WriteLine(); Console.WriteLine(String.Format( "Suffix tree testing: Caught exception: {0;s}", ex.Message)); Console.WriteLine("Note: This program is currently a work in progress."); } } Console.Write("Continue (y or n)? "); Console.Out.Flush(); string continueStr = Console.ReadLine(); if (continueStr == null || continueStr.Length > 0 && continueStr.ToLower()[0] != 'y') { isDone = true; } } }