rails.game
Class PublicCertificate

java.lang.Object
  extended by rails.game.PublicCertificate
All Implemented Interfaces:
java.lang.Cloneable, Certificate, Moveable, PublicCertificateI

public class PublicCertificate
extends java.lang.Object
implements PublicCertificateI, java.lang.Cloneable


Field Summary
protected  java.lang.String certId
          A key identifying the certificate's unique ID
protected  float certificateCount
          Count against certificate limits
protected static java.util.Map<java.lang.String,PublicCertificateI> certMap
          A map allowing to find certificates by unique id
protected  java.lang.String certTypeId
          A key identifying the certificate's unique type
protected  PublicCompanyI company
          From which public company is this a certificate
protected  int indexInCompany
          Index within company (to be maintained in the IPO)
protected  boolean initiallyAvailable
          Availability at the start of the game
protected static org.apache.log4j.Logger log
           
protected  Portfolio portfolio
          Current holder of the certificate
protected  boolean president
          President's certificate?
protected  int shares
          Share percentage represented by this certificate
 
Fields inherited from interface rails.game.move.Moveable
AT_END
 
Constructor Summary
PublicCertificate(int shares, boolean president, boolean available, float certificateCount, int index)
           
PublicCertificate(PublicCertificateI oldCert)
           
 
Method Summary
protected  java.lang.Object clone()
           
 PublicCertificateI copy()
          Clone this certificate
 boolean equals(PublicCertificateI cert)
          Two certificates are "equal" if they both belong to the same company, represent the same share percentage, and are not a president share.
static PublicCertificateI getByUniqueId(java.lang.String certId)
           
 float getCertificateCount()
           
 PublicCompanyI getCompany()
           
 MoveableHolder getHolder()
           
 int getIndexInCompany()
           
 java.lang.String getName()
          Get the name of a certificate.
 Portfolio getPortfolio()
           
 int getShare()
          Get the percentage of ownership that this certificate represents.
 int getShares()
          Get the number of shares that this certificate represents.
 java.lang.String getTypeId()
           
 java.lang.String getUniqueId()
          Set the certificate's unique ID
 boolean isInitiallyAvailable()
           
 boolean isPresidentShare()
           
 void moveTo(MoveableHolder newHolder)
           
 void setCertificateCount(float certificateCount)
           
 void setCompany(PublicCompanyI companyI)
           
 void setInitiallyAvailable(boolean initiallyAvailable)
          Get the current price of this certificate.
 void setPortfolio(Portfolio portfolio)
           
 void setPresident(boolean b)
           
 void setUniqueId(java.lang.String name, int index)
          Set the certificate's unique ID, for use in deserializing
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

company

protected PublicCompanyI company
From which public company is this a certificate


shares

protected int shares
Share percentage represented by this certificate


president

protected boolean president
President's certificate?


certificateCount

protected float certificateCount
Count against certificate limits


initiallyAvailable

protected boolean initiallyAvailable
Availability at the start of the game


portfolio

protected Portfolio portfolio
Current holder of the certificate


certTypeId

protected java.lang.String certTypeId
A key identifying the certificate's unique type


certId

protected java.lang.String certId
A key identifying the certificate's unique ID


indexInCompany

protected int indexInCompany
Index within company (to be maintained in the IPO)


certMap

protected static java.util.Map<java.lang.String,PublicCertificateI> certMap
A map allowing to find certificates by unique id


log

protected static org.apache.log4j.Logger log
Constructor Detail

PublicCertificate

public PublicCertificate(int shares,
                         boolean president,
                         boolean available,
                         float certificateCount,
                         int index)

PublicCertificate

public PublicCertificate(PublicCertificateI oldCert)
Method Detail

setUniqueId

public void setUniqueId(java.lang.String name,
                        int index)
Description copied from interface: PublicCertificateI
Set the certificate's unique ID, for use in deserializing

Specified by:
setUniqueId in interface PublicCertificateI

getUniqueId

public java.lang.String getUniqueId()
Description copied from interface: PublicCertificateI
Set the certificate's unique ID

Specified by:
getUniqueId in interface PublicCertificateI

getIndexInCompany

public int getIndexInCompany()
Specified by:
getIndexInCompany in interface PublicCertificateI

getByUniqueId

public static PublicCertificateI getByUniqueId(java.lang.String certId)

moveTo

public void moveTo(MoveableHolder newHolder)
Specified by:
moveTo in interface Moveable

getPortfolio

public Portfolio getPortfolio()
Specified by:
getPortfolio in interface Certificate
Returns:
Portfolio this certificate belongs to.

getHolder

public MoveableHolder getHolder()
Specified by:
getHolder in interface Moveable

isPresidentShare

public boolean isPresidentShare()
Specified by:
isPresidentShare in interface PublicCertificateI
Returns:
if this is a president's share

getShares

public int getShares()
Get the number of shares that this certificate represents.

Specified by:
getShares in interface PublicCertificateI
Returns:
The number of shares.

getShare

public int getShare()
Get the percentage of ownership that this certificate represents. This is equal to the number of shares * the share unit.

Specified by:
getShare in interface PublicCertificateI
Returns:
The share percentage.

getName

public java.lang.String getName()
Get the name of a certificate. The name is derived from the company name and the share percentage of this certificate. If it is a 100% share (as occurs with e.g. 1835 minors), only the company name is given. If it is a president's share, that fact is mentioned.

Specified by:
getName in interface Certificate
Specified by:
getName in interface Moveable

setInitiallyAvailable

public void setInitiallyAvailable(boolean initiallyAvailable)
Description copied from interface: PublicCertificateI
Get the current price of this certificate.

Specified by:
setInitiallyAvailable in interface PublicCertificateI

isInitiallyAvailable

public boolean isInitiallyAvailable()
Specified by:
isInitiallyAvailable in interface PublicCertificateI
Parameters:
b -

getCertificateCount

public float getCertificateCount()
Specified by:
getCertificateCount in interface PublicCertificateI

setCertificateCount

public void setCertificateCount(float certificateCount)
Specified by:
setCertificateCount in interface PublicCertificateI

setPortfolio

public void setPortfolio(Portfolio portfolio)
Specified by:
setPortfolio in interface PublicCertificateI
Parameters:
portfolio -

setPresident

public void setPresident(boolean b)
Specified by:
setPresident in interface PublicCertificateI
Parameters:
b -

getCompany

public PublicCompanyI getCompany()
Specified by:
getCompany in interface PublicCertificateI
Returns:

setCompany

public void setCompany(PublicCompanyI companyI)
Specified by:
setCompany in interface PublicCertificateI
Parameters:
companyI -

getTypeId

public java.lang.String getTypeId()
Specified by:
getTypeId in interface PublicCertificateI

clone

protected java.lang.Object clone()
Overrides:
clone in class java.lang.Object

copy

public PublicCertificateI copy()
Description copied from interface: PublicCertificateI
Clone this certificate

Specified by:
copy in interface PublicCertificateI

equals

public boolean equals(PublicCertificateI cert)
Two certificates are "equal" if they both belong to the same company, represent the same share percentage, and are not a president share.

Specified by:
equals in interface PublicCertificateI
Parameters:
cert - Public company certificate to compare with.
Returns:
True if the certs are "equal" in the defined sense.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object