Esempio n. 1
0
        private static void Main(string[] args)
        {
            var size = ReadArgs(args);

            var cube = new Core.RubiksCube(size);

            //TODO: Make the formatter something configurable
            var consoleFormatter = new ConsoleFormatter(cube);
            RubiksCubeExpressionParser parser = new RubiksCubeSimpleExpressionParser(cube);

            SetupReadline();

            Console.Clear();

            do
            {
                Console.WriteLine("Use the command \"help\".");
                Console.WriteLine();

                consoleFormatter.Render();

                var input = ReadLine.Read("(move)> ")
                            .Replace("\0", string.Empty);

                //TODO: Implement help command

                if (CheckExitExpression(input))
                {
                    break;
                }

                var result = parser.Parse(input);

                if (!result.Success)
                {
                    Console.Clear();
                    Console.Error.WriteLine(result.ErrorMessage);
                    continue;
                }

                foreach (var movement in result.Movements)
                {
                    cube.Turn(movement);
                }

                Console.Clear();
            } while (true);
        }
        public SimpleExpressionsTests()
        {
            var cube = new Core.RubiksCube(3);

            _parser = new RubiksCubeSimpleExpressionParser(cube);
        }