Java-Adventure-Game / Java-Based Adventure Game main / AdventureGameModel / AdventureObject.java
AdventureObject.java
Raw
package AdventureGameModel;

import java.io.Serializable;

/**
 * This class keeps track of the props or the objects in the game.
 * These objects have a name, description, and location in the game.
 * The player with the objects can pick or drop them as they like and
 * these objects can be used to pass certain passages in the game
 */
public class AdventureObject implements Serializable {
    private String objectName; // the name of the object
    private String description; // the description of the object
    private Room location = null; // the location of the object

    /**
     * Adventure Object Constructor
     * ___________________________
     * This constructor sets the name, description, and location of the object
     *
     * @param name The name of the Object in the game
     * @param description One line description of the Object
     * @param location The location of the Object in the game
     */
    public AdventureObject(String name, String description, Room location){
        this.objectName = name;
        this.description = description;
        this.location = location;
    }

    /**
     * Getter method for the name attribute
     *
     * @return name of the object
     */
    public String getName(){
        return this.objectName;
    }

    /**
     * Getter method for the description attribute
     *
     * @return description of the game
     */
    public String getDescription(){
        return this.description;
    }

    /**
     * This method returns the location of the object if the object is still in
     * the room. If the object has been picked up by the player, it returns null
     *
     * @return returns the location of the object if the objects is still in
     * the room otherwise, returns null
     */
    public Room getLocation(){
        return this.location;
    }
}