示例#1
0
        /// <summary>
        /// Shifts the Robot's position by one place in some direction
        /// </summary>
        /// <param name="move"></param>
        private void Step(MoveCommand move)
        {
            switch (move.Direction)
            {
            case Direction.North:
                position = new Position(position.X, position.Y + 1);
                break;

            case Direction.South:
                position = new Position(position.X, position.Y - 1);
                break;

            case Direction.East:
                position = new Position(position.X + 1, position.Y);
                break;

            case Direction.West:
                position = new Position(position.X - 1, position.Y);
                break;

            default:
                break;
            }

            //adds new position to hashSet, or does nothing if the position has already been recorded.
            recorder.CleanPosition(position);
        }
示例#2
0
 public Robot(CommandSet commandSet, CleaningRecorder recorder)
 {
     this.commandSet = commandSet;
     this.recorder   = recorder;
     this.position   = commandSet.StartingCoords;
     //HashSet should also include starting position to keep accurate account of position's cleaned.
     recorder.CleanPosition(commandSet.StartingCoords);
 }