World of Zuul - adding items using an ArrayList
<p>I am currently trying to improve "World of Zuul" using BlueJ. I am at the point where I have made an <code>Item</code> class and put a few items in there. The next step is to place the items into rooms which I think presents the current problem I am facing: How do you reference or use an <code>ArrayList</code> established in another class? Hopefully if I can understand how that is done, then I may be able to work out how to place a specific item or items in a specific room.</p>

<p>Any help would be appreciated.</p>

<p>Please see my code below:</p>

<p><strong><code>Item</code>class</strong></p>

<pre><code>public Item(String itemDescription, int itemWeight)
{
    // initialise instance variables
    itemDescription = itemDescription;
    itemWeight = itemWeight;
    this.list = new ArrayList&lt;Item&gt;();
    Item item = new Item(itemDescription, itemWeight);

}
/**
 * Name of item
 */
public String getItemDescription()
{
    return itemDescription;
}
/**
 * Weight of an Item
 */
public int itemWeight()
{
    return itemWeight;
}

/**
 * Show items 
 */
public ArrayList&lt;Item&gt; getItems ()
{
    return list;
}
public String getItemString()
{
    String returnString = "Item:";
    {
        returnString += ""+list;
    }
    return returnString;
}
/**
 * Presents name and weight of item
 */
public String toString()
{
    return "Item: " + itemDescription + "Weight " + itemWeight;
}
/**
 * List of items
 */
public void addItem()
{
    list.add(new Item("can of coke",1));
    list.add(new Item("bike",6));
    list.add(new Item("textbook",4)); 
    list.add(new Item("£20 note",1));
    list.add(new Item("stick",2));
    list.add(new Item("Theater leaflet",1));
    list.add(new Item("mobile phone",2));
}
</code></pre>

<p><strong><code>Room</code> class</strong></p>

<pre><code>public class Room 
{
    private String description;
    private HashMap&lt;String, Room&gt; exits;

    public Room(String description) 
    {
        this.description = description;

    }

    /**
     * Define the exits of this room.  Every direction either leads
     * to another room or is null (no exit there).
     * @param north The north exit.
     * @param east The east east.
     * @param south The south exit.
     * @param west The west exit.
     */
    public void setExit(String direction, Room neighbor) 
    {
        exits.put(direction, neighbor);
    }

    public Room getExit(String direction)
    {
        return exits.get(direction);
    }

    /**
     * @return The description of the room.
     */
    public String getDescription()
    {
        return description;
    }

    /**
     * Return a long description of this room, of the form;
     *  You are in the kitchen.
     *  Exits: north west
     *  @return A description of the room, including exits.
     */
    public String getLongDescription()
    {
        return "You are" + description + "./n" +getExitString();
    }

    /**
     * Return a description of the room's exits,
     * for example, "Exits: north west".
     * @return A description of the available exits.
     * 
     */
    public String getExitString()
    {
        String returnString = "Exits:";
        Set&lt;String&gt; keys = exits.keySet();
        for(String exit :keys) {
            returnString += "" + exits;
        }
        return returnString;
    }

}
</code></pre>