/*****
 * Room
 *
 * is a java object that has some number of doors
 * and some number of other objects on the floor.
 *
 * Which variables belong to the whole class?  
 * Which belong to a particular room?  
 * Why did I choose to set them up this way?
 *
 ****/

class Room {
    public static final int NORTH = 0;
    public static final int SOUTH = 1;
    public static final int EAST = 2;
    public static final int WEST = 3;

    public static String[] directions = { "North", "South", "East", "West" };

    private static final int NUMBER_OF_THINGS = 10;
    private static final int NUMBER_OF_DOORS = 4;

    private String	name;
    private String      description;
    private String[]	thingsOnFloor;

    public Room[]	doorTo;

    Room(String itsName){
	name = itsName;
	description = "";
	thingsOnFloor = new String[NUMBER_OF_THINGS];
	doorTo = new Room[NUMBER_OF_DOORS];
    }

    void setDescription(String d){
	description = d;
    }

    void addDoor(int which, Room nextRoom){
	doorTo[which] = nextRoom;
    }

    void addThing(int whichSlot, String theThing){
	thingsOnFloor[whichSlot] = theThing;
    }
    
    String getShortDescription(){
	return name;
    }

    String getLongDescription(){
	String answer = " - " + name + " - \n";
	boolean empty;
	answer += description + "\n";
	answer += "  On the ground you see: \n";
	empty = true;
	for (int i=0; i<NUMBER_OF_THINGS; i++){
	    if ( thingsOnFloor[i] != null ){
		empty = false;
		answer += "   ("+i+") " + thingsOnFloor[i] + "\n";
	    }
	}
	if (empty){
	    answer += "   nothing\n";
	}
	answer += "  You see exits in the following directions: ";
	for (int i=0; i<NUMBER_OF_DOORS; i++){
	    if ( doorTo[i] != null ){
		answer += " "+directions[i];
	    }
	}
	answer += "\n";

	return answer;
    }

}



syntax highlighted by Code2HTML, v. 0.9.1