public class Vehicle
extends java.lang.Object
                | Modifier and Type | Field and Description | 
|---|---|
protected float | 
                                brakeProb
                                    probability of the vehicle to brake without
                                        reason
                                     
                                 | 
                            
protected float | 
                                curVelocity
                                    current velocity of the vehicle 
                                 | 
                            
protected int | 
                                id
                                    a number to index the vehicle 
                                 | 
                            
protected float | 
                                maxVelocity
                                    maximum velocity of the vehicle 
                                 | 
                            
protected float | 
                                position
                                    current position of the vehicle on the
                                        track
                                     
                                 | 
                            
protected float | 
                                trackLength
                                    length of the track the vehicle is placed
                                        on
                                     
                                 | 
                            
| Constructor and Description | 
|---|
Vehicle(int id,
                                    int position,
                                    float maxVelocity,
                                    float brakeProb,
                                    float trackLength)
                                    Constructs a new vehicle. 
                                 | 
                            
| Modifier and Type | Method and Description | 
|---|---|
float | 
                                getCurVelocity()
                                    Getter for curVelocity 
                                 | 
                            
float | 
                                getMaxVelocity()
                                    Getter for maxVelocity 
                                 | 
                            
float | 
                                getPosition()
                                    Getter for position 
                                 | 
                            
void | 
                                setBrakeProb(float brakeProb)
                                    Setter for brakeProb 
                                 | 
                            
void | 
                                setMaxVelocity(float maxVelocity)
                                    Setter for maxVelocity 
                                 | 
                            
void | 
                                timeElapse()
                                    Updates the position of the vehicle according
                                        to it's previously calculated speed.
                                     
                                 | 
                            
void | 
                                updateVelocity(float distanceForerunner)
                                    Calculates the new velocity of the vehicle
                                        based on the following rules:
                                        Increase by one if the vehicle is slower than it's maximum
                                        speed
                                        Random brake by one
                                        Break if the distance to the forerunner is less than it's
                                        speed
                                     
                                 | 
                            
protected int id
protected float position
protected float curVelocity
protected float maxVelocity
protected float brakeProb
protected float trackLength
public Vehicle(int id,
               int position,
               float maxVelocity,
               float brakeProb,
               float trackLength)
                                id - a number to index the vehicleposition - current position of the vehicle on
                                        the track
                                    maxVelocity - maximum velocity of the vehicle
                                    brakeProb - probability of the vehicle to brake
                                        without reason
                                    trackLength - length of the track the vehicle
                                        is placed on
                                    public float getPosition()
public float getCurVelocity()
public float getMaxVelocity()
public void setBrakeProb(float brakeProb)
public void setMaxVelocity(float maxVelocity)
public void updateVelocity(float distanceForerunner)
distanceForerunner - distance to the forerunner
                                        of the vehicle
                                    public void timeElapse()