java.lang.Object AlleyWalker
public class AlleyWalker
A class that simulates a random alley walk.
Constructor Summary | |
---|---|
AlleyWalker()
Constructs a random alley walker. |
Method Summary | |
---|---|
int |
getNumSteps()
Gets the number of steps taken by the walker so far. |
int |
getPosition()
Gets the current position of the walker (relative to its starting place). |
void |
reset()
Resets the position and number of steps for the walker. |
void |
step()
Simulates a single step of the walker, randomly moving one position to the right (the positive direction) or to the left (the negative direction). |
void |
stepToDistance(int distance)
Simulates repeated steps of the walker, until it reaches a specific distance from its starting place (in either direction). |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AlleyWalker()
Method Detail |
---|
public int getNumSteps()
public int getPosition()
public void reset()
public void step()
public void stepToDistance(int distance)
distance
- the distance the walker must reach before stopping