コード例 #1
0
ファイル: MoveAttempter.cs プロジェクト: screwed99/Toy-Robot
 public MoveAttempter(
     IMoveStateTransformer moveStateTransformer,
     ITableDimensions tableDimensions)
 {
     this.moveStateTransformer = moveStateTransformer;
     this.tableDimensions      = tableDimensions;
 }
コード例 #2
0
 public PlacePerformer(
     IRobotStateFactory robotStateFactory,
     ITableDimensions tableDimensions,
     int xCoordinate,
     int yCoordinate,
     IOrientation orientation)
 {
     this.robotStateFactory = robotStateFactory;
     this.tableDimensions   = tableDimensions;
     this.xCoordinate       = xCoordinate;
     this.yCoordinate       = yCoordinate;
     this.orientation       = orientation;
 }
コード例 #3
0
 public CommandPerformerFactory(
     IRobotStateFactory robotStateFactory,
     IOrientationTurner leftOrientationTurner,
     IOrientationTurner rightOrientationTurner,
     IMoveAttempter moveAttempter,
     ITableDimensions tableDimensions,
     ITextOutputter textOutputter)
 {
     this.robotStateFactory      = robotStateFactory;
     this.leftOrientationTurner  = leftOrientationTurner;
     this.rightOrientationTurner = rightOrientationTurner;
     this.moveAttempter          = moveAttempter;
     this.tableDimensions        = tableDimensions;
     this.textOutputter          = textOutputter;
 }
コード例 #4
0
        public ToyRobotAssembly(ITextInputter textInputter, ITextOutputter textOutputter, ITableDimensions tableDimensions)
        {
            var initialRobotState        = new NotPlacedRobotState();
            var toyRobot                 = new ToyRobot.ToyRobot(initialRobotState);
            var robotStateFactory        = new RobotStateFactory();
            var robotStateBuilderFactory = new RobotStateBuilderFactory();
            var leftOrientationTurner    =
                new LeftOrientationTurner(robotStateBuilderFactory);
            var rightOrientationTurner =
                new RightOrientationTurner(robotStateBuilderFactory);
            var moveStateTransformer =
                new MoveStateTransformer(robotStateBuilderFactory);
            var moveAttempter           = new MoveAttempter(moveStateTransformer, tableDimensions);
            var commandPerformerFactory = new CommandPerformerFactory(
                robotStateFactory,
                leftOrientationTurner,
                rightOrientationTurner,
                moveAttempter,
                tableDimensions,
                textOutputter);
            var orientationFactory  = new OrientationParser();
            var reportCommandParser = new ReportCommandParser(commandPerformerFactory);
            var moveCommandParser   = new MoveCommandParser(commandPerformerFactory);
            var leftCommandParser   = new LeftCommandParser(commandPerformerFactory);
            var rightCommandParser  = new RightCommandParser(commandPerformerFactory);
            var placeCommandParser  = new PlaceCommandParser(
                commandPerformerFactory, orientationFactory);
            var commandParsers = new ICommandParser[]
            {
                reportCommandParser,
                moveCommandParser,
                leftCommandParser,
                rightCommandParser,
                placeCommandParser
            };
            var masterCommandParser = new MasterCommandParser(commandParsers);
            var commandHandler      = new CommandHandler(toyRobot, masterCommandParser);
            var commandReader       = new CommandReader(commandHandler);

            this.ToyRobotDriver = new ToyRobotDriver(textInputter, commandReader);
        }