public void ProcessLine(string line) { if (line.Substring(0, RectangleInstruction.RECTANGLE.Length).Equals(RectangleInstruction.RECTANGLE)) { RectangleInstruction rectangleInstruction = new RectangleInstruction(line); ProcessRectangleInstruction(rectangleInstruction); } else if (line.Substring(0, RotateRowInstruction.ROTATE_ROW.Length).Equals(RotateRowInstruction.ROTATE_ROW)) { RotateRowInstruction rotateRowInstruction = new RotateRowInstruction(line, screenDisplay.GetLength(1)); ProcessRotateRow(rotateRowInstruction); } else if (line.Substring(0, RotateColumnInstruction.ROTATE_COLUMN.Length).Equals(RotateColumnInstruction.ROTATE_COLUMN)) { RotateColumnInstruction rotateColumnInstruction = new RotateColumnInstruction(line, screenDisplay.GetLength(0)); ProcessRotateColumn(rotateColumnInstruction); } }
/// <summary> /// Turns on the top left hand corner of the _screenDisplay array by the specified amount. /// </summary> /// <param name="rectangleSize">String representation of the width and height to turn on e.g "4x2"</param> public void ProcessRectangleInstruction(RectangleInstruction rectangleInstruction) { if (rectangleInstruction.x > screenDisplay.GetLength(1)) { throw new ArgumentOutOfRangeException("x", rectangleInstruction.x, $"Rectangle width {rectangleInstruction.x} is greater than display size {screenDisplay.GetLength(1)}"); } if (rectangleInstruction.y > screenDisplay.GetLength(0)) { throw new ArgumentOutOfRangeException("y", rectangleInstruction.y, $"Rectangle height {rectangleInstruction.y} is greater than display size {screenDisplay.GetLength(0)}"); } //Always start in top left hand corner for (int i = 0; i < rectangleInstruction.x; i++) { for (int j = 0; j < rectangleInstruction.y; j++) { screenDisplay[j, i] = true; } } }