From 1d53c4c00f555914194bea1dcd21e991ff0a3d5f Mon Sep 17 00:00:00 2001 From: Lukasz Baldyga Date: Mon, 2 Nov 2020 12:23:18 +0000 Subject: [PATCH] Documented Commander --- .../Commander.cs | 46 ++++++++++++++++++- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Advanced Software Engineering/Advanced Software Engineering/Commander.cs b/Advanced Software Engineering/Advanced Software Engineering/Commander.cs index 66d6883..09d672d 100644 --- a/Advanced Software Engineering/Advanced Software Engineering/Commander.cs +++ b/Advanced Software Engineering/Advanced Software Engineering/Commander.cs @@ -5,12 +5,19 @@ using System.Drawing.Drawing2D; using System.Linq; namespace Advanced_Software_Engineering { + /// + /// The commander class takes care of commands. It also takes control of the drawer. + /// public class Commander { Graphics graphics; List commands = new List(); Drawer drawer; + /// + /// This command updates the graphics element (usually) when the page repaints. + /// + /// The graphics element to be updated public void DrawAllCommands(Graphics updateGraphicsElement) { graphics = updateGraphicsElement; drawer.ResetDrawer(); @@ -21,27 +28,47 @@ namespace Advanced_Software_Engineering { } } + /// + /// Create a new Commander instance. + /// + /// initial graphics object public Commander(Graphics graphics) { this.graphics = graphics; this.drawer = new Drawer(this.graphics); drawer.ResetDrawer(); } - public Commander(string command) { + /// + /// Creates a new Commander instance without a context. Should only be used for testing purpouses. + /// + /// empty string + public Commander(string command = "") { Console.WriteLine("Warning! No graphics context!!!"); } + /// + /// Creates a new Commander instance with a graphics context and commands to process right off the bat. + /// + /// Graphics contetx + /// Commands to process public Commander(Graphics graphics, string rawCommands) { this.graphics = graphics; this.drawer = new Drawer(this.graphics); this.ProcessCommands(rawCommands); drawer.ResetDrawer(); } - + /// + /// Adds a verb to the command list to be executed. + /// + /// Verb to be added public void AddCommand(Verb command) { commands.Add(command); } + /// + /// processes commands. Removes all commands if it fails parsing the raw commands. + /// + /// Processes commands seperated by \n or \r\n public void ProcessCommands(string rawCommands) { //ignore case rawCommands = rawCommands.ToLower(); @@ -81,6 +108,10 @@ namespace Advanced_Software_Engineering { } + /// + /// Processes the commands and executes them at the same time. It's the same as + /// + /// Processes commands seperated by \n or \r\n public void ProcessCommandsAndExecute(string rawCommands) { int start = commands.Count; ProcessCommands(rawCommands); @@ -90,11 +121,18 @@ namespace Advanced_Software_Engineering { } } + /// + /// Removes all commands from the Commander and resets the drawer. + /// public void RemoveAllCommands() { commands = new List(); drawer.ResetDrawer(); } + /// + /// Explains all of the commands in order + /// + /// Explanation of all the commands public string ExplainCommands() { string desc = ""; foreach (Verb command in commands) { @@ -103,6 +141,10 @@ namespace Advanced_Software_Engineering { return desc; } + /// + /// Get the numder of commands inside the Commader + /// + /// Integer number of commands public int GetNumberOfCommands() { return commands.Count; }