Global Positioning System Reference
In-Depth Information
No matter how complex and sophisticated the technical ROAF components
are, the ROAF architect should always try to make design choices that
simplify RoApp layers and allow for rapid development of the scenario
semantics. Thus, the LondonChasePlayer serves as the abstract base class
for the implementation of a concrete player to actually play the game. The
base class hides client-server connectivity, initialization, etc. The extending
player should focus on playing a smart game and not be distracted with
technology.
Every player class can (has to) implement its own strategy to win the
game. During construction time, the developer should always be able to
run the player client for testing and to troubleshoot problems. And every
player should have a main method with the arguments to its home directory
and properties file to begin with.
abstract class LCPlayer extends RealObject
public class RandomPlayer extends LCPlayer
The LCPlayer is an abstract template and requires a concrete extension
to supply its name, role, and identity to actually become a player. The
quickest and minimum implementation is a RandomPlayer to simplify the
actual (intelligent) decision process to choose the next move. Developers
can use this player as a starting point for their own player and gradually
make it smarter.
public LCPlayer( gpsInfo, name, role, ID )
public RandomPlayer( gpsInfo, name, role, ID )
The cascaded constructors set the necessary attributes to participate
in the game: gpsInfo satisfies the RealObject . Other attributes are stored
in the LCPlayer . Valid roles are predefined in the RemoteObjectsApplication
interface. Since the game only requires two roles, the integer values are
hard-coded, along with the human-readable strings:
public static final String[] ROROLES = {"Chaser","Runner"};
public static final int CHASER = 0, RUNNER = 1;
The method setIdentity(ObjectID) is overridden with a final
method and does not allow a change of ID after it is set via constructor (a
way to hide an inherited method):
private class RemotePlayerClient
extends RemoteClient
implements RemotePlayer
The inner class RemoteClient was introduced in Chapter 10 (page 133)
to implement methods of the RemoteObject interface. And we just (see
page 174) used the covariant return type to override the returned class with
 
Search WWH ::




Custom Search