1  public class Train
  2  {
  3     private double distanceFromTerminus;
  4  
  5     public void move(double distanceMoved)
  6     {
  7        distanceFromTerminus = distanceFromTerminus + distanceMoved;
  8     }
  9  
 10     public double getPosition()
 11     {
 12        return distanceFromTerminus;
 13     }
 14  }