@@ -0,0 +1,2638 @@
+/*%0A * File: AdvObject.java%0A * --------------------%0A * This file defines a class that models an object in the%0A * Adventure game.%0A */%0A%0Aimport java.util.Scanner;%0A%0A/* Class: AdvObject */%0A/**%0A * This class defines an object in the Adventure game. An object is%0A * characterized by the following properties:%0A *%0A * %3Cul%3E%0A * %3Cli%3EIts name, which is the noun used to refer to the object%0A * %3Cli%3EIts description, which is a string giving a short description%0A * %3Cli%3EThe room number in which the object initially lives%3C/li%3E%0A *%0A * The external format of the objects file is described in the assignment%0A * handout. The comments on the methods exported by this class show how to use%0A * the initialized data structure.%0A */%0A%0Apublic class AdvObject %7B%0A%0A%09/* Method: getName() */%0A%09/**%0A%09 * Returns the object name, which is the word used to refer to it.%0A%09 *%0A%09 * @usage String name = obj.getName();%0A%09 * @return The name of the object%0A%09 */%0A%09public String getName() %7B%0A%09%09return this.objName;%0A%09%7D%0A%0A%09/* Method: getDescription() */%0A%09/**%0A%09 * Returns the one-line description of the object. This description should%0A%09 * start with an article, as in %22a set of keys%22 or %22an emerald the size of a%0A%09 * plover's egg.%22%0A%09 *%0A%09 * @usage String name = obj.getDescription();%0A%09 * @return The description of the object%0A%09 */%0A%09public String getDescription() %7B%0A%09%09return this.description;%0A%09%7D%0A%0A%09/* Method: getInitialLocation() */%0A%09/**%0A%09 * Returns the initial location of the object.%0A%09 *%0A%09 * @usage int roomNumber = obj.getInitialLocation();%0A%09 * @return The room number in which the object initially resides%0A%09 */%0A%09public int getInitialLocation() %7B%0A%09%09return this.objLocation;%0A%09%7D%0A%0A%09/* Method: readFromFile(scan) */%0A%09/**%0A%09 * Reads the data for this object from the Scanner scan, which must have%0A%09 * been opened by the caller. This method returns the object if the object%0A%09 * initialization is successful; if there are no more objects to read,%0A%09 * readFromFile returns null%0A%09 * %0A%09 * @usage AdvObject object = AdvObject.readFromFile(scan);%0A%09 * @param scan%0A%09 *            A Scanner open on the objects data file%0A%09 * @return the object if an object is successfully read; null at end of file%0A%09 */%0A%09public static AdvObject readFromFile(Scanner scan) %7B%0A%09%09AdvObject obj = new AdvObject();%0A%09%09do %7B%0A%09%09%09obj.objName = scan.nextLine();%0A%09%09%09obj.description = scan.nextLine();%0A%09%09%09obj.objLocation = scan.nextInt();%0A%09%09%09// get rid of the blank line at int%0A%09%09%09scan.nextLine();%0A%09%09%7D while (scan.hasNext() && !scan.nextLine().trim().equals(%22%22));%0A%09%09return obj;%0A%09%7D%0A%0A%09/* Private instance variables */%0A%09// Add your own instance variables here%0A%09private String objName;%0A%09private String description;%0A%09private int objLocation;%0A%7D%0A

Create AdvObject.java