The Exit class is far simpler than the Location class. We need store only a few details (such as the room location, and the direction of the exit). Its important when designing object though to think of how they will be used and called. In a text adventure gaming system, the direction north might be represented in more than one form. We might have a full name of 'north', and a shortened version 'n'.
Rather than leaving this work up to the game application, I've designed the Exit object so that both shortened strings, and full name strings, are stored in the object. A calling application can call methods to access both forms, and when an exit is constructed, they can use pre-defined constants to represent common directions.
The actual construction of the Exit object is quite straightforward. I've provided get/set methods as in the Location object, and defined constants that allow us to create Exit objects representing common directions.
Now that we've created our two primary classes for this simplified version of a text-adventure gaming system, we can create a simple applet to demonstrate their use.