All pastes #46463 Raw Edit

Something

public text v1 · immutable
#46463 ·published 2006-03-21 11:39 UTC
rendered paste body
public class Weapon extends Objects
{
	//attributes of weapons.. weapons could be spells thus the area of effect
	int speed;
	int damage;
	int area;
	//String nameOfWeapon; NOT needed any more...
	

	//constructor.. damage should store dice roll..
	public Weapon(String name)
	{
		if("longsword".equalsIgnoreCase(name))
		{
			super.nameOfObject= "Long Sword";
			speed = 5;
			damage = 8;
			area = 1;
		}
		else if("shortsword".equalsIgnoreCase(name))
		{
			super.nameOfObject = "Short Sword";
			speed = 3;
			damage = 6;
			area = 1;
		}
		else if("magic missile".equalsIgnoreCase(name))
		{
			super.nameOfObject= "Magic Missile";
			speed = 1;
			damage = 5;
			area = 10;
		}
	}
        
        //Second overload of constructor... here you do not "call" the super() constructor...
	public Weapon(String name, int xSpeed, int xDamage, int xArea)
	{
		speed = xSpeed;
		damage = xDamage;
		area = xArea;
		super.nameOfObject = name;
	}

	public void setSpeed(int xSpeed)
	{
		speed = xSpeed;
	}

	public void setDamage(int xDamage)
	{
		damage = xDamage;
	}

	public void setArea(int xArea)
	{
		area = xArea;
	}

	public int getSpeed()
	{
		return speed;
	}

	public int getDamage()
	{
		return damage;
	}

	public int getArea()
	{
		return area;
	}

	

}

**************************************************************************************
OBJECTS

public class Objects
{
	String nameOfObject;
	
	//constructor
	
	public Objects(String name)
	{
		nameOfObject = name;
		
		
	}

}