//TODO: the "object[] args" parameter feels super gross and wrong. Needs to be changed at some point. //Perhaps declaring some sort of IInstructionArguments (generic?) would make more sense and simplify //the code in this method. //REFACTOR: It works for now, though, so I'll (hopefully) have time to come back to this. public void InterpretInstruction(Instruction instruction, object[] args) { switch (instruction) { case Instruction.PLACE: if (TryParsePlaceArguments(args, out int xArg, out int yArg, out Orientation orientationArg)) { //TODO: Create IPositionFactory, or perhaps better, output a IVector directionalPlacement from the above //TryParsePlaceArguments, which can contain Position and Orientation data for us. _robot.Place(new Position(xArg, yArg), orientationArg); } break; case Instruction.MOVE: if (_robot.IsPlaced) { _robot.Move(); } break; case Instruction.LEFT: if (_robot.IsPlaced) { _robot.Rotate(SpinDirection.LEFT); } break; case Instruction.RIGHT: if (_robot.IsPlaced) { _robot.Rotate(SpinDirection.RIGHT); } break; case Instruction.REPORT: if (_robot.IsPlaced) { _reporter.Report(_robot.GetPosition(), _robot.GetOrientation().Value); } break; default: return; } }