Esempio n. 1
0
  /**
   * Initialize this new projectile in a given world, at given position, with given propulsion, in
   * given direction, with given radius and with which weapon it is fired.
   *
   * @param position the position of the projectile
   * @param world the world the projectile is in
   * @param Propulsion the propulsion with what the projectile is launched
   * @param Direction the direction of the projectile
   * @param radius the radius of the projectile
   * @param weapon the weapon from which the projectile is fired
   * @post The yield of this new projectile equals the given propulsion | new.getYield() ==
   *     propulsion
   * @effect The weapon with which this new projectile will be fired equals the given weapon |
   *     setWeapon(weapon)
   * @effect This new projectile is initialized as a moving object with given radius, given
   *     direction, in given world and at the given position. | super(radius, position, world,
   *     weapon.getMass(),Direction)
   */
  public Projectile(
      Position position,
      World world,
      int Propulsion,
      double Direction,
      double radius,
      Weapon weapon)
      throws IllegalArgumentException, IllegalPositionException, IllegalWorldException {
    super(radius, position, world, weapon.getMass(), Direction);
    if (!isValidYield(Propulsion)) throw new IllegalArgumentException("not a valid yield");

    this.setWeapon(weapon);

    this.yield = Propulsion;
  }
Esempio n. 2
0
 /** This method returns the mass of the projectile of the selected weapon. */
 @Raw
 public int getMassProjectile() {
   return weapon.getMass();
 }