Class mazebject
Purpose
mazeObject is the super class of all object classes(Block, Room, Door, Item, Player).
Everything, blocks, items,
rooms, doors,
players, in this environment is an object. Those objects have some characteristics
in common. For example, each object should have its selfId and belongId to identify
which object it is and which object it belongs to. Besides, in some situation,
we cannot tell what kind of objects they really are and therefore just look at them
as they are of the same class and treat them in the same way. These are the reasons
why the class mazeObject is designed.
Functionality
Basically, all the methods in mazeObject are virtual. Each object class has its own
methods. The methods in mazeObject is to give you an error message when you misuse
a method which does not exist in the certain object class.
Important Data/Method
- int selfId:
a unique ID to identify which object it is.
- int belongId:
belongId is to identify which object does the mazeObject belong to. All
objects except blocks belong to some other certain object. For example, a door of
a room belongs to that room; a player in a room belongs to that room; an item taked
by a player belongs to that player.
Comments
- When client requests a block and server exports it to the client, all of the belonging objects
has to export first so that the following belonged object can find their parent to append to.
for example, a block has to transfer before any rooms that belonged to this block. A room has
to be sent before any doors or items belonged to this room sent. The objects construction happen
in mapStructure.java
- Here we take advantage of java's polymorphism, every object is a derived class of the mazeObject,
so that in many situations, we don't have to know exactly what the object currently is and call
its method, we just call a method that is defined virtually in the mazeObject.class and the right
object will be signaled to do its corresponding method.
See also
Block
Room
Door
Item
Player
[Go to Class Index Table]
[Go back to Program Architecture Diagram]
[Source Code of AllObjects.java]