diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index edc3db2..35bac08 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -116,7 +116,7 @@ namespace Assignment_1 return true; } - bool List() + void List() { Console.WriteLine("┌" + new string('─', 49) + "┐"); Console.WriteLine("│{0:-15}│{1:-25}│{2:9}│", "Symbol", "Value", "Flags"); @@ -134,7 +134,49 @@ namespace Assignment_1 Console.WriteLine("├" + new string('─', 15) + "┼" + new string('─', 25) + "┼" + new string('─', 9) + "┤"); } } - + } + void Exit() + { + Environment.Exit(0); + } + bool Print(Stream source, int mode=0) + { + string expression; + long result = FindExpression(source, out expression); + if (result < 0) + { + // Could not print + return false; + } + if (mode == 0) + { + Console.WriteLine(expression); + } + else if (mode == 1) + { + Console.Write("Length of the expression is: "); + Console.WriteLine(expression.Length); + } + else if (mode >= 2) + { + + string[] words = expression.Split(' '); + if (mode == 3) + { + Console.Write("Wordcount is: "); + Console.WriteLine(words.Length); + } + else + { + Console.WriteLine("Words are:"); + foreach (string word in words) + { + Console.WriteLine(word); + } + } + + } + return true; }