package org.lucci.madhoc.env;
import java.util.Random;
import org.lucci.math.Utilities;
public abstract class MobilityMedium
{
public static class Car extends MobilityMedium
{
public Car(Random random)
{
setMaximumSpeed(130 / 3.6);
setSpeed(Utilities.getRandomBetween(10/3.6, getMaximumSpeed(), random));
setSpeed(50/3.6);
}
public String getName()
{
return "Car";
}
}
public static class Legs extends MobilityMedium
{
public Legs(Random random)
{
setMaximumSpeed(10 / 3.6);
setSpeed(Utilities.getRandomBetween(3/3.6, getMaximumSpeed(), random));
}
public String getName()
{
return "Pedestrian";
}
}
public static class Train extends MobilityMedium
{
public Train(Random random)
{
setMaximumSpeed(250 / 3.6);
setSpeed(150 / 3.6);
}
public String getName()
{
return "Train";
}
}
private double speed = 0;
private double maximumSpeed = 0;
private double angle;
public double getSpeed()
{
return speed;
}
public void setSpeed(double i)
{
if ( i < 0 )
throw new IllegalArgumentException();
speed = i;
}
public double getAngle()
{
return angle;
}
public void setAngle(double d)
{
while (d < 0)
{
d += 2 * Math.PI;
}
this.angle = d % (2 * Math.PI);
}
public double getMaximumSpeed()
{
return maximumSpeed;
}
public void setMaximumSpeed(double i)
{
if ( i < 0 )
throw new IllegalArgumentException();
maximumSpeed = i;
}
public abstract String getName();
}