package model.state;

import util.JSONable;

/**
 * A state object that has a name and description. Essentially used to create states with associated
 * name and description metadata.
 * 
 * @author Jonathan, Nishad, Rahul
 *
 */
public abstract class DescribableState implements JSONable{

    private String myName;
    private String myDescription;

    protected DescribableState (String name) {
        myName = name;
        myDescription = "";
    }

    public void updateName (String name) {
        myName = name;
    }

    public void updateDescription (String description) {
        myDescription = description;
    }

    public String getName () {
        return myName;
    }

    public String getDescription () {
        return myDescription;
    }

    @Override
    public String toString () {
        return getName();
    }

    @Override
    public int hashCode () {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((myDescription == null) ? 0 : myDescription.hashCode());
        result = prime * result + ((myName == null) ? 0 : myName.hashCode());
        return result;
    }

    @Override
    public boolean equals (Object obj) {
        if (this == obj) return true;
        if (obj == null) return false;
        if (getClass() != obj.getClass()) return false;
        DescribableState other = (DescribableState) obj;
        if (myDescription == null) {
            if (other.myDescription != null) return false;
        }
        else if (!myDescription.equals(other.myDescription)) return false;
        if (myName == null) {
            if (other.myName != null) return false;
        }
        else if (!myName.equals(other.myName)) return false;
        return true;
    }

}

@@ -344,16 +344,59 @@
 ription;
+%0A    private final int myHashingPrime = 31;
 %0A%0A    pr
@@ -502,392 +502,1354 @@
     
-public void updateName (String name) %7B%0A        myName = name;%0A    %7D%0A%0A    public void updateDescription (String description) %7B%0A        myDescription = description;%0A    %7D%0A%0A    public String getName () %7B%0A        return myName;%0A    %7D%0A%0A    public String getDescription () %7B%0A        return myDescription;%0A    %7D%0A%0A    @Override%0A    public String toString () %7B%0A        return getName();%0A    %7D%0A
+/**%0A     * Sets the name of the DescribableState%0A     * %0A     * @param name%0A     *        the name of the describable state %0A     */%0A    public void updateName (String name) %7B%0A        myName = name;%0A    %7D%0A%0A    /**%0A     * Sets the description of the DescribableState%0A     * %0A     * @param description%0A     *        the description of the describable state%0A     */%0A    public void updateDescription (String description) %7B%0A        myDescription = description;%0A    %7D%0A%0A    /**%0A     * Returns the name of the DescribableState%0A     * %0A     * @return name%0A     *         the name of the describable state%0A     */%0A    public String getName () %7B%0A        return myName;%0A    %7D%0A%0A    /**%0A     * Returns the description of the DescribableState%0A     * %0A     * @return description%0A     *         the description of the describable state%0A     */%0A    public String getDescription () %7B%0A        return myDescription;%0A    %7D%0A%0A    /**%0A     * Returns the Stringified version of the Describable State%0A     * %0A     * @return String%0A     *         a concatenated string of the name and description%0A     */%0A    @Override%0A    public String toString () %7B%0A        return getName() + getDescription();%0A    %7D%0A%0A    /**%0A     * Returns the hashcode of the describable state for comparison%0A     * %0A     * @return int%0A     *         the custom hashcode of the describable state%0A     */
 %0A   
@@ -1914,19 +1914,71 @@
 prime = 
-31;
+myHashingPrime; // Large prime helps prevent collisions
 %0A       
@@ -2190,24 +2190,85 @@
 ult;%0A    %7D%0A%0A
+    /**%0A     * Checks equality of describable states%0A     */%0A
     @Overrid

improve comments in DescribableState.java, and extracted hashing prime to final int