//=================================================================================================
public class CloneCop implements Cloneable {
//-------------------------------------------------------------------------------------------------
    private String name;
    private CloneGun bigGun;
//-------------------------------------------------------------------------------------------------
    public CloneCop() {

        name = null;
        bigGun = null;
    }
//-------------------------------------------------------------------------------------------------
    public CloneCop(String name) {

        this();
        this.name = name;
    }
//-------------------------------------------------------------------------------------------------
    public CloneCop clone() {

        CloneCop newCop;

        try {
            newCop = (CloneCop)super.clone();
            newCop.setGun(bigGun.clone());
            return(newCop);
        } catch (CloneNotSupportedException e) {
            System.out.println("Could not clone cop " + e.getMessage());
            return(null);
        }
    }
//-------------------------------------------------------------------------------------------------
    public boolean equals(CloneCop otherCop) {

        return(otherCop != null && name.equals(otherCop.name) &&
((bigGun == null && otherCop.bigGun == null) ||
 (bigGun != null && otherCop.bigGun != null && bigGun.equals(otherCop.bigGun))));
    }
//-------------------------------------------------------------------------------------------------
    public String toString() {

        String displayString;

        displayString = "Officer " + name;
        if (bigGun != null) {
            displayString += " has a " + bigGun;
        } else {
            displayString += " has no gun";
        }
        return(displayString);
    }
//-------------------------------------------------------------------------------------------------
    public void setGun(CloneGun newGun) {

        bigGun = newGun;
    }
//-------------------------------------------------------------------------------------------------
    public void fireGun() {

        bigGun.fire();
    }
//-------------------------------------------------------------------------------------------------
    public void loadGun() {

        bigGun.load();
    }
//-------------------------------------------------------------------------------------------------
}
//=================================================================================================
