コード例 #1
0
        /// <summary>
        /// rotate column x=A by B shifts all of the pixels in column A (0 is the left column) down by B pixels.
        /// Pixels that would fall off the bottom appear at the top of the column.
        /// </summary>
        /// <param name="instruction">e.g. "x=3 by 2"</param>
        public void ProcessRotateColumn(RotateColumnInstruction rotateColumnInstruction)
        {
            int height = screenDisplay.GetLength(0);

            bool[,] copyOfScreenDisplay = (bool[, ])screenDisplay.Clone();
            for (int i = 0; i < height; i++)
            {
                screenDisplay[(i + rotateColumnInstruction.shiftAmount) % height, rotateColumnInstruction.column] = copyOfScreenDisplay[i, rotateColumnInstruction.column];
            }
        }
コード例 #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);
     }
 }