universe.server.database
Class GalaxyBase

java.lang.Object
  |
  +--universe.common.database.DBItem
        |
        +--universe.server.database.GalaxyBase
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
GalaxyGliese, GalaxyStd, GalaxyTest

public abstract class GalaxyBase
extends DBItem

Abstract class from which all concrete classes used to represent galaxies in the game are to be derived. This class contains implementation of basic primitive methods for the storage and manipulation of standard galaxy attributes. Subclasses merely have to override the generateSystems method to ensure that star systems and their planets are created as per the nature of the galaxy (e.g. randomly determined, loaded from a data file, a combination of the above, etc.).

Version:
$Id: GalaxyBase.java,v 1.7 2002/02/27 07:14:31 sstarkey Exp $
See Also:
GalaxyStd, GalaxyGliese, Serialized Form

Field Summary
private static GalaxyID currentID
           
private  boolean HasGeneratedSystems
           
private  GalaxyID ID
           
private  java.lang.String name
           
private  java.util.Vector systems
           
 
Constructor Summary
(package private) GalaxyBase()
          Designated constructor - generates unique ID for the galaxy object and adds it to the list of galaxies in the game.
(package private) GalaxyBase(boolean dummy)
          Constructor for GalaxyUndefined.
 
Method Summary
 void addSystem(SystemID SID)
          Adds a System to the Galaxy
 void generateSystems(float[] planetDistribution)
          This method should be extended by subclasses to causes the receiving galaxy to generate the collection of star systems and associated planets which it will contain.
 GalaxyID getID()
          Return the ID
 Index getIndex()
           
 java.lang.String getName()
           
 java.util.Vector getSystems()
          Returns the galaxy's system list
 boolean hasGeneratedSystems()
          Returns true if the galaxy has been populated with star systems and their planets, and false if this has not yet been done.
 void setName(java.lang.String in_name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

currentID

private static GalaxyID currentID

ID

private GalaxyID ID

name

private java.lang.String name

systems

private java.util.Vector systems

HasGeneratedSystems

private boolean HasGeneratedSystems
Constructor Detail

GalaxyBase

GalaxyBase()
Designated constructor - generates unique ID for the galaxy object and adds it to the list of galaxies in the game. Subclasses must call this method in their constructor to ensure proper registration with the game.


GalaxyBase

GalaxyBase(boolean dummy)
Constructor for GalaxyUndefined. N.B. Does not register this instance with the game as one present in the game since its used to represent bogus or unknown galaxy information.

Method Detail

getID

public GalaxyID getID()
Return the ID


getIndex

public Index getIndex()
Specified by:
getIndex in class DBItem
See Also:
in the subclasses for a typed version.

getName

public java.lang.String getName()
Specified by:
getName in class DBItem

setName

public void setName(java.lang.String in_name)

addSystem

public void addSystem(SystemID SID)
Adds a System to the Galaxy


getSystems

public java.util.Vector getSystems()
Returns the galaxy's system list


hasGeneratedSystems

public boolean hasGeneratedSystems()
Returns true if the galaxy has been populated with star systems and their planets, and false if this has not yet been done. This method is primarily used as a guard to prevent the calling of generateSystems() more than once.

See Also:
generateSystems()

generateSystems

public void generateSystems(float[] planetDistribution)
                     throws SchemeUnknownException,
                            java.lang.InterruptedException
This method should be extended by subclasses to causes the receiving galaxy to generate the collection of star systems and associated planets which it will contain. Calls to this method after the galaxy is already populated with star systems should have no effect, and it is the responsiblity of subclasses to do this by checking the value returned from the hasGeneratedSystems method.

Parameters:
planetDistribution - Array of floating point values representing the probability of planetary mass at successive distances from its primary.
Throws:
SchemeUnknownException - If unable to determine a ID of the galaxy to which systems are to be added.
java.lang.InterruptedException - If access to a resource needed for star system generation has been interrupted.
See Also:
hasGeneratedSystems


Copyright © 2001 Universe Dev Team All Rights Reserved.