package project; /** * A thing in the world of Grinnell. There are many kinds * of things. * * @author CSC152 2004F * @version 1.0 of November 2004 */ import java.util.Hashtable; public class Thing implements ThingPerson { //Field String name; String description; Hashtable verbs; // hold the integer as per checkVerb Hashtable attributes; //dictionary of attributes //Constructors public Thing() {} //observers /** * Get the name of this thing. Every thing is supposed to have a * unique name. */ public String getName() { return this.name; } /** * Get a description of the object, which can then be presented * to the user. */ public String describe() { return this.description; } /** *finds the verbs that can be performed on said object */ public Hashtable verbs() { return this.verbs; } /** *finds the stuff needed to run a verb *returns a -1 if the verb doesn't exist for this object *returns a 0 if the verb does exist but does not change anything *returns a 1 if the verb exists and changes things */ public Integer checkVerb(String verb) { if (this.verbs.get(verb).equals(null)) return new Integer(-1); else { Integer returned = (Integer) this.verbs.get(verb); return returned; } } /** *gets attributes stored as numbers */ public double getNumberAttribute(String name) { Double returned = (Double) this.attributes.get(name); return returned.doubleValue(); } /** *gets atributes stored as words */ public String getWordAttribute(String name) { String returned = (String) this.attributes.get(name); return returned; } public void changeNumberAttribute(String name, Double newValue) { this.attributes.put(name, newValue); } public void changeWordAttribute(String name, String newName) { this.attributes.put(name, newName); } } // class Thing