コード例 #1
0
 @Override
 public RadarController generate(Integer numberOfEnemies) {
   if (numberOfEnemies == 1) {
     logger.info("Using SingleEnemyOscillateScanner because we are fighting against 1 enemy");
     return new SingleEnemyOscillateScanner(robot);
   } else {
     logger.info("Using MultipleEnemyScanner because we are fighting against multiple enemies");
     return new MultipleEnemyScanner(robot);
   }
 }
コード例 #2
0
/**
 * RadarControllerFactory.java
 *
 * @author Gilberto J Requena (GJR)
 */
public class RadarControllerFactory implements Factory<Integer, RadarController> {

  private static final Logger logger = Logger.getLogger("Radar");
  private AdvancedRobot robot;

  public RadarControllerFactory(AdvancedRobot robot) {
    this.robot = robot;
  }

  @Override
  public RadarController generate(Integer numberOfEnemies) {
    if (numberOfEnemies == 1) {
      logger.info("Using SingleEnemyOscillateScanner because we are fighting against 1 enemy");
      return new SingleEnemyOscillateScanner(robot);
    } else {
      logger.info("Using MultipleEnemyScanner because we are fighting against multiple enemies");
      return new MultipleEnemyScanner(robot);
    }
  }
}