Esempio n. 1
0
        public ToyRobotAssembly(ITextInputter textInputter, ITextOutputter textOutputter, int numRobots)
        {
            var robotStateFactory        = new RobotStateFactory();
            var robotStateBuilderFactory = new RobotStateBuilderFactory();
            var leftOrientationTurner    =
                new LeftOrientationTurner(robotStateBuilderFactory);
            var rightOrientationTurner =
                new RightOrientationTurner(robotStateBuilderFactory);
            var moveStateTransformer =
                new MoveStateTransformer(robotStateBuilderFactory);
            var tableDimensions         = new TableDimensions();
            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 commandReader       = InitializeCommandReader(numRobots, masterCommandParser);

            this.ToyRobotDriver = new ToyRobotDriver(textInputter, commandReader);
        }
 public void Setup()
 {
     TableDimensions = new TableDimensions(TableSize, TableSize);
     Robot           = new Robot(TableDimensions);
     Factory         = new RobotCommandFactory();
 }
 public void Setup()
 {
     TableDimensions = new TableDimensions(TableSize, TableSize);
     Robot           = new Robot(TableDimensions);
 }