Exemple #1
0
        /// <summary>
        /// rotate row y=A by B shifts all of the pixels in row A (0 is the top row) right by B pixels.
        /// Pixels that would fall off the right end appear at the left end of the row.
        /// </summary>
        /// <param name="instruction">e.g "y=5 by 20"</param>
        public void ProcessRotateRow(RotateRowInstruction rotateRowInstruction)
        {
            int width = screenDisplay.GetLength(1);

            bool[,] copyOfScreenDisplay = (bool[, ])screenDisplay.Clone();
            for (int i = 0; i < width; i++)
            {
                screenDisplay[rotateRowInstruction.row, (i + rotateRowInstruction.shiftAmount) % width] = copyOfScreenDisplay[rotateRowInstruction.row, i];
            }
        }
Exemple #2
0
 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);
     }
 }