コード例 #1
0
        public void GoUp()
        {
            ThrowIfCanNotMove();
            var direction = Direction.Up;

            if (IsDownMoving(Head.CurPosition, BodyFirst.CurPosition))
            {
                direction = TurnBack();
            }
            DirectionQueue.Enqueue(direction);
        }
コード例 #2
0
        public void GoLeft()
        {
            ThrowIfCanNotMove();
            var direction = Direction.Left;

            if (IsRightMoving(Head.CurPosition, BodyFirst.CurPosition))
            {
                direction = TurnBack();
            }
            DirectionQueue.Enqueue(direction);
        }