public static DataResult <StartPositions> ValidationStartPositions(string val)
        {
            DataResult <StartPositions> dataResult;
            StartPositions startPositions = StartPositions.Instance;

            try
            {
                var _startPositions = val.Trim().Split(' ');
                if (_startPositions.Count() == 3)
                {
                    startPositions.X         = Convert.ToInt32(_startPositions[0]);
                    startPositions.Y         = Convert.ToInt32(_startPositions[1]);
                    startPositions.Direction = (EnumDirections)Enum.Parse(typeof(EnumDirections), _startPositions[2].ToUpper());
                    dataResult = new DataResult <StartPositions>(startPositions, true);
                }
                else
                {
                    throw new Exception();
                }
            }
            catch (Exception)
            {
                dataResult = new DataResult <StartPositions>(startPositions, false, Resources.ValidationStartPositions);
            }

            return(dataResult);
        }
예제 #2
0
 public Creater(IMachine machine, StartPositions startPositions, string moves, List <int> maxPoints)
 {
     _machine        = machine;
     _startPositions = startPositions;
     _moves          = moves;
     _maxPoints      = maxPoints;
 }
예제 #3
0
        public void MoveInSameDirection(StartPositions positions)
        {
            switch (positions.Direction)
            {
            case EnumDirections.N:
                positions.Y += 1;
                break;

            case EnumDirections.S:
                positions.Y -= 1;
                break;

            case EnumDirections.E:
                positions.X += 1;
                break;

            case EnumDirections.W:
                positions.X -= 1;
                break;

            default:
                break;
            }
        }
예제 #4
0
        public void Rotate90Right(StartPositions positions)
        {
            switch (positions.Direction)
            {
            case EnumDirections.N:
                positions.Direction = EnumDirections.E;
                break;

            case EnumDirections.E:
                positions.Direction = EnumDirections.S;
                break;

            case EnumDirections.S:
                positions.Direction = EnumDirections.W;
                break;

            case EnumDirections.W:
                positions.Direction = EnumDirections.N;
                break;

            default:
                break;
            }
        }