Java Reference
In-Depth Information
16-3. The MUD example of this chapter uses remote objects to represent the
rooms or places in the MUD and the people interacting in the MUD. Things
that appear in the MUD, however, are not remote objects; they are simply
part of the state of each room in the MUD.
Modify the example so that things are true remote objects. Define a
MudThing interface that extends Remote . It should have a getDescription()
method that returns the description of a thing. Modify the MudPlace interface
and RemoteMudPlace class to have methods that allow MudThing objects to
be added to and removed from a place.
Define a trivial implementation of MudThing that simply returns a static string
from its getDescription() method. Then, define another implementation of
MudThing , named Clock . This class should have more dynamic behavior:
whenever its getDescription() method is called, it should return a string
that displays the current time. Modify the MUD server so that it places a
Clock object in the entrance to the MUD.
16-4. Modify the MUD example again so that MudPerson objects can pick up
MudThing objects they find in a MudPlace , carry them around, drop them in
other places, and give them to other people. Implement at least three new
methods: pickup() , drop() , and give() . Modify the MUD client so that it
supports pickup, drop, and give commands.
Search WWH ::




Custom Search