net.kolls.railworld.play
Class RailAccident

java.lang.Object
  extended by java.lang.Throwable
      extended by java.lang.Exception
          extended by java.lang.RuntimeException
              extended by net.kolls.railworld.play.RailAccident
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
HeadOn, OverRun, RearEnd, SideOn

public abstract class RailAccident
extends java.lang.RuntimeException

Describes an accident and the train(s) involed. In the future, this may be replaced with an abstract class or interface, and the various kinds of accidents be subclasses. This would allow scripts to extend the game and add their own accident types (e.g. failing to blow horn before crossing)

Author:
Steve Kollmansberger
See Also:
Serialized Form

Field Summary
 java.awt.geom.Point2D pos
          The location of the accident.
 Train t1
          The trains involved in the accident.
 Train t2
          The other train.
 
Constructor Summary
RailAccident(Train first, Train second, java.awt.geom.Point2D p)
          Create a rail accident.
 
Method Summary
abstract  java.lang.String midbody()
          The midbody of the report is the section that comes before the second train, if any, is described but after the first train is described.
abstract  java.lang.String title()
          The title of this accident type
 
Methods inherited from class java.lang.Throwable
fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

t1

public Train t1
The trains involved in the accident. t1 must not be null.


t2

public Train t2
The other train. t2 may be null if there is only one train involved.


pos

public java.awt.geom.Point2D pos
The location of the accident.

Constructor Detail

RailAccident

public RailAccident(Train first,
                    Train second,
                    java.awt.geom.Point2D p)
Create a rail accident.

Parameters:
first - The first train. Must not be null.
second - The second train. May be null if only one train involved.
p - The point on the map where the accident occured.
Method Detail

title

public abstract java.lang.String title()
The title of this accident type

Returns:
Title based on kind of accident

midbody

public abstract java.lang.String midbody()
The midbody of the report is the section that comes before the second train, if any, is described but after the first train is described. It is a sentence fragment like "collided head-on with a" (which becomes "A southbound 40-ton train collided head-on with a 30-ton train...") Do not end the phrase with a period or start with a capital. If you want the direction for the second train, you can insert {2d} into the string and that will be replaced by the second train direction.

Returns:
midbody phrase