Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Weapon Class

By: a guest on Dec 6th, 2012  |  syntax: Java  |  size: 1.20 KB  |  views: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. package anonymousweaponprototype.classes;
  2.  
  3. import anonymousweaponprototype.interfaces.WeaponInterface;
  4. import java.awt.geom.Point2D;
  5. import java.util.Random;
  6.  
  7. /**
  8.  *
  9.  * @author Darin Beaudreau
  10.  */
  11. public class Weapon implements WeaponInterface {
  12.     // Constant variables.
  13.     // Member variables.
  14.     private String name;
  15.     public String getName() { return name; }
  16.     private int damage;
  17.     public int getDamage() { return damage; }
  18.     private double speed;
  19.     public double getSpeed() { return speed; }
  20.     private int ammo;
  21.     public int getAmmo() { return ammo; }
  22.     public void useAmmo() { ammo -= ammoPerShot; }
  23.     private int ammoPerShot;
  24.     public int getAmmoPerShot() { return ammoPerShot; }
  25.    
  26.     private Random r;
  27.     public int getRandomDamage() { return r.nextInt(damage)+1; }
  28.    
  29.     public Weapon(String name_, int damage_, double speed_, int ammo_, int ammoPerShot_) {
  30.         name = name_;
  31.         damage = damage_;
  32.         speed = speed_;
  33.         ammo = ammo_;
  34.         ammoPerShot = ammoPerShot_;
  35.        
  36.         r = new Random();
  37.     }
  38.  
  39.     @Override
  40.     public void fire(Point2D target_) {
  41.         // Do nothing. Defined by anonymous inner classes.
  42.     }
  43. }