/* 
	JCavernApplet.java

	Title:			JCavern And Glen
	Author:			Bill Walker
	Description:	
*/

package jcavern;

/**
 * A Sword is a Thing the player uses to attack combatants.
 *
 * @author	Bill Walker
 * @version	$Id$
 */
public class Sword extends Treasure
{
	public static final double	kWearFraction = 0.1;
	
	private int					mStrength;
	private int					mCharges;
	
	public Sword(String aName, int strength)
	{
		super(aName);
		mStrength = strength;
		
		/* charges := charges + Random(10) + 2; */
		mCharges = (int) (Math.random() * 10 + 2);
	}
	
	public void decrementCharges()
	{
		mCharges--;
	}
	
	public boolean isDepleted()
	{
		return mCharges <= 0;
	}
	
	public Object clone()
	{
		return new Sword(new String(getName()), mStrength);
	}
	
	public int getStrength()
	{
		return mStrength;
	}
	
	public String toString()
	{
		return getName() + " +" + (mStrength - 1);
	}
}	

@@ -411,51 +411,8 @@
 %0A%09%7B%0A
-%09%09super(aName);%0A%09%09mStrength = strength;%0A%09%09%0A
 %09%09/*
@@ -458,18 +458,29 @@
 /%0A%09%09
-mCharges =
+this(aName, strength,
  (in
@@ -506,16 +506,142 @@
  10 + 2)
+);%0A%09%7D%0A%09%0A%09public Sword(String aName, int strength, int charges)%0A%09%7B%0A%09%09super(aName);%0A%09%09mStrength = strength;%0A%09%09mCharges = charges
 ;%0A%09%7D%0A%09%0A%09

add an extra constructor for when you want to explicitly set the number of charges for a sword