Esempio n. 1
0
        public override void Process(List <Node> nodes, INotationParser parser)
        {
            var index = nodes.IndexOf(this);

            // 1 * ( 2 + 3 ) ==> 1 2 3 + *
            // 1 * ( 2 + 3 ) ==> * 1 + 2 3

            var leftNode  = parser.GetLeftNode(nodes, index);
            var rightNode = parser.GetRightNode(nodes, index);

            Left  = leftNode;
            Right = rightNode;

            if (parser.WrapOperators() && (rightNode is SymbolNode r) && r.Symbol.Priority > Symbol.Priority)
            {
                var parenth = new ParenthesisNode {
                    InternalNode = rightNode, Type = ParenthesisType.Wrap
                };
                Right = parenth;
            }

            if (parser.WrapOperators() && (leftNode is SymbolNode l) && l.Symbol.Priority > Symbol.Priority)
            {
                var parenth = new ParenthesisNode {
                    InternalNode = leftNode, Type = ParenthesisType.Wrap
                };
                Left = parenth;
            }

            nodes.Remove(leftNode);
            nodes.Remove(rightNode);
        }
Esempio n. 2
0
        internal RubiksCube(INotationParser parser, ICubieConfigurator configurator, int cubeSize)
        {
            _faces = new Dictionary <RubiksDirection, CubeFace>();
            _faces.Add(RubiksDirection.Front, new CubeFace(RubiksDirection.Front, cubeSize));
            _faces.Add(RubiksDirection.Back, new CubeFace(RubiksDirection.Back, cubeSize));
            _faces.Add(RubiksDirection.Up, new CubeFace(RubiksDirection.Up, cubeSize));
            _faces.Add(RubiksDirection.Down, new CubeFace(RubiksDirection.Down, cubeSize));
            _faces.Add(RubiksDirection.Left, new CubeFace(RubiksDirection.Left, cubeSize));
            _faces.Add(RubiksDirection.Right, new CubeFace(RubiksDirection.Right, cubeSize));
            _cubeSize = cubeSize;

            _parser = parser;

            _cubies = configurator.CreateCubies(cubeSize);
        }
Esempio n. 3
0
 public RubiksCube(INotationParser parser, int cubeSize = 3)
     : this(parser, new SolvedPuzzleCubieConfigurator(), cubeSize)
 {
 }
Esempio n. 4
0
 public override void Process(List <Node> nodes, INotationParser parser)
 {
     // Number nodes just have a value and have no further processing.
 }
Esempio n. 5
0
 public NotationNinja(INotationParser parser)
 {
     _parser = parser;
 }
Esempio n. 6
0
 public override void Process(List <Node> nodes, INotationParser parser)
 {
     throw new NotImplementedException();
 }
Esempio n. 7
0
 public abstract void Process(List <Node> nodes, INotationParser parser);