de.hagenah.diplomacy.map
Class Phase

java.lang.Object
  extended by de.hagenah.diplomacy.map.Phase
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, java.lang.Comparable

public final class Phase
extends java.lang.Object
implements java.lang.Cloneable, java.lang.Comparable, java.io.Serializable

The Phase class represents a phase like Spring 1901 Movement.

See Also:
Serialized Form

Field Summary
 int MAX_YEAR
          Maximum allowed year of the phase
 int MIN_YEAR
          Minimum allowed year of the phase
 
Constructor Summary
Phase(int year, boolean fall, boolean retreat, boolean adjustment)
          Creates a new Phase Object.
Phase(java.lang.String name)
          Creates a Phase object for the string "(S|F|W|Spring|Fall|Winter)xxxx((M|R|B|A)X?
 
Method Summary
 boolean canSucceed(Phase nextphase)
          Can nextphase succeed to this phase?
protected  java.lang.Object clone()
           
 int compareTo(java.lang.Object obj)
          Compares two Phases
 boolean equals(java.lang.Object obj)
          Compares two Phases
 Phase getSuccessor(boolean retreats, boolean builds)
          Determines the next phase.
 int getYear()
           
 int hashCode()
          Returns a hashcode for this Phase.
 boolean isAdjustment()
           
 boolean isFall()
           
 boolean isMovement()
           
 boolean isRetreat()
           
 boolean isSpring()
           
 java.lang.String toShortString()
          Returns a short string (sxxxxp) e.g.
 java.lang.String toString()
          Returns a string e.g.
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

MIN_YEAR

public final int MIN_YEAR
Minimum allowed year of the phase

See Also:
Constant Field Values

MAX_YEAR

public final int MAX_YEAR
Maximum allowed year of the phase

See Also:
Constant Field Values
Constructor Detail

Phase

public Phase(int year,
             boolean fall,
             boolean retreat,
             boolean adjustment)
      throws java.lang.IllegalArgumentException
Creates a new Phase Object.

Parameters:
year - Year (MIN_YEAR..MAX_YEAR)
fall -
retreat -
adjustment - Only the following combinations are valid:
  • false,false,false
  • false,true,false
  • true,false,false
  • true,true,false
  • true,false,true
Throws:
java.lang.IllegalArgumentException

Phase

public Phase(java.lang.String name)
      throws java.lang.IllegalArgumentException
Creates a Phase object for the string "(S|F|W|Spring|Fall|Winter)xxxx((M|R|B|A)X?|Movement|Retreat|Build|Adjustment)".

Parameters:
name - Phase String (!=null).
Throws:
java.lang.IllegalArgumentException
Method Detail

getYear

public int getYear()

isSpring

public boolean isSpring()

isFall

public boolean isFall()

isMovement

public boolean isMovement()

isRetreat

public boolean isRetreat()

isAdjustment

public boolean isAdjustment()

canSucceed

public boolean canSucceed(Phase nextphase)
Can nextphase succeed to this phase?


getSuccessor

public Phase getSuccessor(boolean retreats,
                          boolean builds)
Determines the next phase.

Parameters:
retreats - Are any retreats neccessary?
builds - Are any builds neccessary?
Returns:
The next phase

clone

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

equals

public boolean equals(java.lang.Object obj)
Compares two Phases

Overrides:
equals in class java.lang.Object

compareTo

public int compareTo(java.lang.Object obj)
Compares two Phases

Specified by:
compareTo in interface java.lang.Comparable

hashCode

public int hashCode()
Returns a hashcode for this Phase.

Overrides:
hashCode in class java.lang.Object

toString

public java.lang.String toString()
Returns a string e.g. "Winter 1901 Adjustment".

Overrides:
toString in class java.lang.Object

toShortString

public java.lang.String toShortString()
Returns a short string (sxxxxp) e.g. "W1901A".