private void switchWithplaces(int[] array, string message, int leftIndex, int rightIndex, State state) { Console.Clear(); Console.ResetColor(); Console.ForegroundColor = textColor; Console.WriteLine(message); Console.WriteLine(); int[] switchedArray = (int[])array.Clone(); int tmp = switchedArray[leftIndex]; switchedArray[leftIndex] = switchedArray[rightIndex]; switchedArray[rightIndex] = tmp; DisplayMatrix displayMatrix = generateDispalyMatrix(switchedArray, message, leftIndex, rightIndex, state); for (int i = 0; i < displayMatrix.getHeight(); i++) { for (int j = 0; j < displayMatrix.getWidth(); j++) { Console.ForegroundColor = displayMatrix.getArrayTuple()[i, j].Item1; Console.Write(displayMatrix.getArrayTuple()[i, j].Item2); } Console.WriteLine(); } }
private void liftUp(int[] array, string message, int leftIndex, int rightIndex, State state) { Console.Clear(); Console.ResetColor(); Console.ForegroundColor = textColor; Console.WriteLine(message); Console.WriteLine(); DisplayMatrix displayMatrix = generateDispalyMatrix(array, message, leftIndex, rightIndex, state); for (int i = 0; i < displayMatrix.getHeight(); i++) { for (int j = 0; j < displayMatrix.getWidth(); j++) { Console.ForegroundColor = displayMatrix.getArrayTuple()[i, j].Item1; Console.Write(displayMatrix.getArrayTuple()[i, j].Item2); } Console.WriteLine(); } }
public override void animate(int[] array, string message, int leftIndex, int rightIndex, State state) { Console.Clear(); Console.ResetColor(); Console.ForegroundColor = textColor; string finalMessage = !string.IsNullOrEmpty(message) ? message : convertStateToMessage(state, leftIndex, rightIndex); Console.WriteLine(finalMessage); Console.WriteLine(); DisplayMatrix displayMatrix = generateDispalyMatrixSameLine(array, message, leftIndex, rightIndex, state); for (int i = 0; i < displayMatrix.getHeight(); i++) { for (int j = 0; j < displayMatrix.getWidth(); j++) { Console.ForegroundColor = displayMatrix.getArrayTuple()[i, j].Item1; Console.Write(displayMatrix.getArrayTuple()[i, j].Item2); } Console.WriteLine(); } }