rails.game
Class CompanyType

java.lang.Object
  extended by rails.game.CompanyType
All Implemented Interfaces:
CompanyTypeI, ConfigurableComponentI

public class CompanyType
extends java.lang.Object
implements CompanyTypeI

Objects of this class represent a particular type of company, of which typically multiple instances exist in a rails.game. Examples: "Private", "Minor", "Major", "Mountain" etc.

This class contains common properties of the companies of one type, and aids in configuring the companies by reducing the need to repeatedly specify common properties with different companies.


Field Summary
protected  int capitalisation
           
protected  java.lang.String className
           
protected  java.util.List<CompanyI> companies
           
protected  java.lang.String name
           
 
Fields inherited from interface rails.game.CompanyTypeI
ALL_CLOSE_TAG, AUCTION_TAG, CLASS_TAG, ELEMENT_ID, NAME_TAG
 
Constructor Summary
CompanyType(java.lang.String name, java.lang.String className)
          The constructor.
 
Method Summary
 void configureFromXML(Tag tag)
          Instructs the component to configure itself from the provided XML element.
 CompanyI createCompany(java.lang.String name, Tag tag)
           
 void finishConfiguration(GameManagerI gameManager)
          This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first.
 int getCapitalisation()
           
 java.lang.String getClassName()
          Get the name of the class that will implement this type of company.
 java.util.List<CompanyI> getCompanies()
           
 CompanyI getDummyCompany()
           
 java.lang.String getName()
          Get the company type name
 void setCapitalisation(int mode)
           
 void setCapitalisation(java.lang.String mode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

protected java.lang.String name

className

protected java.lang.String className

capitalisation

protected int capitalisation

companies

protected java.util.List<CompanyI> companies
Constructor Detail

CompanyType

public CompanyType(java.lang.String name,
                   java.lang.String className)
The constructor.

Parameters:
name - Company type name ("Private", "Public", "Minor" etc.).
className - Name of the class that will instantiate this type of company.
element - The <CompanyType> DOM element, used to define this company type.
Method Detail

configureFromXML

public void configureFromXML(Tag tag)
                      throws ConfigurationException
Description copied from interface: ConfigurableComponentI
Instructs the component to configure itself from the provided XML element.

Specified by:
configureFromXML in interface ConfigurableComponentI
Throws:
ConfigurationException
See Also:
rails.game.ConfigurableComponentI#configureFromXML(org.w3c.dom.Element)

finishConfiguration

public void finishConfiguration(GameManagerI gameManager)
Description copied from interface: ConfigurableComponentI
This method is intended to be called for each configurable component, to perforn any initialisation activities that require any other components to be initialised first. This includes creating any required relationships to other configured components and objects.

This method should be called where necessary after all XML file parsing has completed, so that all objects that need to be related to do exist.

Specified by:
finishConfiguration in interface ConfigurableComponentI
Parameters:
gameManager - The 'parent' configurable component is passed to allow the 'child' to access any other object without the need to resort to static calls where possible.

createCompany

public CompanyI createCompany(java.lang.String name,
                              Tag tag)
                       throws ConfigurationException
Specified by:
createCompany in interface CompanyTypeI
Throws:
ConfigurationException

getName

public java.lang.String getName()
Get the company type name

Specified by:
getName in interface CompanyTypeI
Returns:
The name of this company type.

getClassName

public java.lang.String getClassName()
Get the name of the class that will implement this type of company.

Specified by:
getClassName in interface CompanyTypeI
Returns:
The full class name.

getCompanies

public java.util.List<CompanyI> getCompanies()
Specified by:
getCompanies in interface CompanyTypeI

setCapitalisation

public void setCapitalisation(int mode)
Specified by:
setCapitalisation in interface CompanyTypeI

setCapitalisation

public void setCapitalisation(java.lang.String mode)
Specified by:
setCapitalisation in interface CompanyTypeI

getCapitalisation

public int getCapitalisation()
Specified by:
getCapitalisation in interface CompanyTypeI

getDummyCompany

public CompanyI getDummyCompany()
Specified by:
getDummyCompany in interface CompanyTypeI