package mug13; /** * An action that is performed in the world. For convenience, subject, * verb, and object are all stored in lowercase. * * @author Samuel A. Rebelsky * @version 1.0 of November 2004 */ public class Action { // +--------+-------------------------------------------------- // | Fields | // +--------+ /** * The name of the person who performs the action. */ String subject; /** * The action performed. */ String verb; /** * The object of the action. Set to null if there is * no object. */ String object; // +--------------+-------------------------------------------- // | Constructors | // +--------------+ /** * Build a new action with subject, verb, and object */ public Action(String _subject, String _verb, String _object) { // The next line calls the other constructor (the // no-object constructor) for uniformity. this(_subject,_verb); this.object = _object.toLowerCase(); } // Action(String,String,String) /** * Build a new action with subject and verb, but no object. */ public Action(String _subject, String _verb) { this.subject = _subject.toLowerCase(); this.verb = _verb.toLowerCase(); this.object = null; } // Action(String, String) // +---------+------------------------------------------------- // | Methods | // +---------+ /** * Get the subject of this action. */ public String getSubject() { return this.subject; } // getSubject() /** * Get the verb for this action. */ public String getVerb() { return this.verb; } // getVerb() /** * Get the object of this action. Returns null if there * is no object. */ public String getObject() { return this.object; } // getObject() } // class Action