Package ch.bfh.ti.kybernetik.engine.controller.lightBulb

Source Code of ch.bfh.ti.kybernetik.engine.controller.lightBulb.LightBulbControllerFactory

/**
* Copyright (C) BFH www.bfh.ch 2011
* Code written by: Patrick Dobler, Marc Folly
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
package ch.bfh.ti.kybernetik.engine.controller.lightBulb;

import ch.bfh.ti.kybernetik.engine.controller.roboter.RoboterConstruction;
import ch.bfh.ti.kybernetik.engine.controller.roboter.RoboterController;
import ch.bfh.ti.kybernetik.engine.model.LightBulb;
import ch.bfh.ti.kybernetik.engine.model.Roboter;
import ch.bfh.ti.kybernetik.lego.ki.RoboterKI;

/**
* The Factory to create new {@link LightBulbController} instances
*
*/
public class LightBulbControllerFactory {

  private static final int DEFAULT_LIGHTBULB_RADIUS = 333;
  private static final int DEFAULT_LIGHTBULB_INTENSITY = 700;
  private static final int DEFAULT_LIGHTBULB_Y = 450;
  private static final int DEFAULT_LIGHTBULB_X = 400;

  /**
   * Create a new {@link LightBulbController} having a statically set
   * {@link LightBulb} model instance
   *
   * @return a new {@link LightBulbController} with the default
   *         {@link LightBulb} model
   */
  public static LightBulbController createDefaultLightBulbController() {
    LightBulbController lightBulbController = new DefaultLightBulbControllerImpl(new LightBulb(DEFAULT_LIGHTBULB_X,
        DEFAULT_LIGHTBULB_Y, DEFAULT_LIGHTBULB_INTENSITY, DEFAULT_LIGHTBULB_RADIUS));
    return lightBulbController;

  }

  /**
   * Creates a new {@link LightBulbController} with a random {@link LightBulb}
   * Model
   *
   * @param maxX
   *            the max x-coordinate of the random {@link LightBulb} Model
   * @param maxY
   *            the max y-coordinate of the random {@link LightBulb} Model
   * @return
   */
  public static LightBulbController createRandomLightBulbConroller(int maxX, int maxY) {
    LightBulbController lightBulbController = createDefaultLightBulbController();
    lightBulbController.getLightBulb().setX(generateNumberBetweenRange(10, maxX));
    lightBulbController.getLightBulb().setY(generateNumberBetweenRange(10, maxY));
    lightBulbController.getLightBulb().setMaxIntensity(generateNumberBetweenRange(200, 600));
    lightBulbController.getLightBulb().setMaxRadius(generateNumberBetweenRange(100, 400));
    return lightBulbController;
  }

  private static int generateNumberBetweenRange(int min, int max) {
    return min + (int) (Math.random() * ((max - min) + 1));
  }

}
TOP

Related Classes of ch.bfh.ti.kybernetik.engine.controller.lightBulb.LightBulbControllerFactory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.