//=================================================================================================
public class CloneGun implements Cloneable {
//-------------------------------------------------------------------------------------------------
    private String make;
    private int bulletCapacity;
    private int bulletsAvailable;
//-------------------------------------------------------------------------------------------------
    public CloneGun() {

        make = null;
        bulletCapacity = 0;
        bulletsAvailable = 0;
    }
//-------------------------------------------------------------------------------------------------
    public CloneGun(String make,int bulletCapacity) {

        this();
        this.make = make;
        this.bulletCapacity = bulletCapacity;
    }
//-------------------------------------------------------------------------------------------------
    public CloneGun clone() {

        try {
            return((CloneGun)super.clone());
        } catch (CloneNotSupportedException e) {
            System.out.println("Could not clone gun " + e.getMessage());
            return(null);
        }
    }
//-------------------------------------------------------------------------------------------------
    public boolean equals(CloneGun otherGun) {

        return(otherGun != null && make.equals(otherGun.make) &&
bulletCapacity == otherGun.bulletCapacity && bulletsAvailable == otherGun.bulletsAvailable);
    }
//-------------------------------------------------------------------------------------------------
    public String toString() {

         return(make + ", " + bulletsAvailable + "/" + bulletCapacity + " bullets");
    }
//-------------------------------------------------------------------------------------------------
    public void load() {

        bulletsAvailable = bulletCapacity;
    }
//-------------------------------------------------------------------------------------------------
    public void fire() {

        if (bulletsAvailable > 0) {
            System.out.println("Bang");
            bulletsAvailable--;
        } else {
            System.out.println("Click");
        }
    }
//-------------------------------------------------------------------------------------------------
}
//=================================================================================================
