class LunarLander extends Object
Modifier and Type | Field and Description |
---|---|
static int |
GRAVITY
The gravitational constant for the moon (in meters/second/second)
|
static int |
INITIAL_ALTITUDE
The initial altitude of the lander (in meters)
|
static int |
INITIAL_FUEL
The initial amount of fuel (number of thrusts) available to the lander
|
static int |
INITIAL_VELOCITY
The initial velocity of the lander (in meters/second)
|
static int |
SAFE_LANDING
The maximum speed at which the lander can safely land (in meters/second)
|
static int |
THRUST
The thrust acceleration generated by consuming one unit of fuel (in meters/second/second)
|
Constructor and Description |
---|
LunarLander()
Constructs a new LunarLander in the initial (default) configuration.
|
Modifier and Type | Method and Description |
---|---|
int |
getAltitude()
The current altitude of the lander (in meters).
|
int |
getFuel()
The current amount of fuel remaining.
|
int |
getVelocity()
The current velocity of the lander (in meters/second).
|
void |
reset()
Restores the Lander to its initial (default) configuration.
|
void |
thrust()
Request one unit of fuel be burned to generate upward thrust.
|
void |
tick()
Updates state of lander based on current velocity, thrust requests since the last update,
altitude, and remaining fuel available.
|
public static final int INITIAL_VELOCITY
public static final int INITIAL_ALTITUDE
public static final int INITIAL_FUEL
public static final int GRAVITY
public static final int THRUST
public static final int SAFE_LANDING
public LunarLander()
public void reset()
public int getAltitude()
public int getVelocity()
public int getFuel()
public void thrust()
public void tick()