From b2b8a036e9ab1cf28ce6724b51d2c85bb320c3c6 Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Thu, 11 Mar 2021 16:39:15 +1300 Subject: [PATCH] Added the ~~print~~list function --- Assignment 1/Program.cs | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/Assignment 1/Program.cs b/Assignment 1/Program.cs index 7a48992..46ba527 100644 --- a/Assignment 1/Program.cs +++ b/Assignment 1/Program.cs @@ -10,7 +10,8 @@ namespace Assignment_1 enum VariableFlags { Empty = 0, - Reserved = 1 + Reserved = 1, + NoPrint = 2 } /// @@ -23,10 +24,10 @@ namespace Assignment_1 static Dictionary> Symbols = new Dictionary> { - { "SPACE", new Tuple(" ", VariableFlags.Reserved) }, - { "TAB", new Tuple("\t", VariableFlags.Reserved) }, - { "NEWLINE", new Tuple("\n", VariableFlags.Reserved) }, - { "CARRIAGE_RETURN", new Tuple("\r", VariableFlags.Reserved) } + { "SPACE", new Tuple(" ", VariableFlags.Reserved | VariableFlags.NoPrint) }, + { "TAB", new Tuple("\t", VariableFlags.Reserved | VariableFlags.NoPrint) }, + { "NEWLINE", new Tuple("\n", VariableFlags.Reserved | VariableFlags.NoPrint) }, + { "CARRIAGE_RETURN", new Tuple("\r", VariableFlags.Reserved | VariableFlags.NoPrint) } }; static void Main(string[] args) { @@ -115,6 +116,31 @@ namespace Assignment_1 return true; } + bool List() + { + Console.WriteLine("┌" + new string('─', 49) + "┐"); + Console.WriteLine("│{0:-15}│{1:-25}│{2:9}│", "Symbol", "Value", "Flags"); + Console.WriteLine("├" + new string('─', 15) + "┼" + new string('─', 25) + "┼" + new string('─', 9) + "┤"); + int keyPos = Symbols.Count; + foreach (var item in Symbols) + { + Console.WriteLine("│{0:-15}│{1:-25}│{2:9}│", item.Key, item.Value.Item1, Convert.ToString((byte)item.Value.Item2,2).PadLeft(8,'0')); + if (keyPos == Symbols.Count-1) + { + Console.WriteLine("└" + new string('─', 15) + "┴" + new string('─', 25) + "┴" + new string('─', 9) + "┘"); + } + else + { + Console.WriteLine("├" + new string('─', 15) + "┼" + new string('─', 25) + "┼" + new string('─', 9) + "┤"); + } + } + + return true; + } + + bool + + #endregion #region Data Handling // Data Handling