public class RangedWeapon
extends Weapon
{
private Projectile proj;
public RangedWeapon(String name, int ld, int hd, int db,
Projectile p)
{
super(name, ld, hd, db);
proj = p;
}
public RangedWeapon(String name, int ld, int hd, int db, String pname, int pdi)
{
super(name, ld, hd, db);
proj = new Projectile(pname, pdi);
}
public int getProjectileDamageIncrease()
{
return proj.getDamageIncrease();
}
public String getProjectileName()
{
return proj.getName();
}
public void setProjectile(Projectile
p)
{
proj = p;
}
public void setProjectile(String pname, int pdi)
{
proj = new Projectile(pname, pdi);
}
@Override
public String getName()
{
return name + " & " + proj.getName();
}
@Override
public String getDescriptiveName()
{
return super.getDescriptiveName() + " & " + proj.getName();
}
@Override
public int getLowDamage()
{
return lowDamage + proj.getDamageIncrease();
}
@Override
public int getHighDamage()
{
return highDamage + proj.getDamageIncrease();
}
@Override
public int getDamageAmount()
{
int dif = getHighDamage() - getLowDamage();
int dmg = getLowDamage()
+ (int)(Math.random() * (dif + 1)) + damageBonus;
return dmg;
}
@Override
public String toString()
{
String combinedName
= getDescriptiveName();
int myLd = getLowDamage();
int myHd = getHighDamage();
return combinedName + "(" + myLd + "-" + myHd + ")" + " + " + damageBonus;
}
}
|