All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class gerken.vehicles.Vehicle

java.lang.Object
   |
   +----gerken.vehicles.SimulationParticipant
           |
           +----gerken.vehicles.Vehicle

public class Vehicle
extends SimulationParticipant

A Vehicle is a simulation participant that has the ability to move about the simulation area. Each vehicle has a single VehicleNetwork that processes information about the vehicles' environment (gathered by light receptors in the network) and then drives two motors (one for each rear wheel). As a result, the vehcile is able to respond to its environment by moving. across the simulation area.

This software is provided on an as-is basis and is copyright Chris Gerken. The only rights granted to you are to enjoy and learn from this software.

See Also:
VehicleNetwork

Constructor Index

 o Vehicle(double, double, double, Color, VehicleNetwork)
Return a vehicle at location (x,y), facing in direction d, colored c and driven by network n.

Method Index

 o addBreaksColor(Color)

Adds c to the set of participant colors that the vehicle can break.

 o addBrokenByColor(Color)

Adds c to the set of participant colors that can break the vehicle.

 o blue(double, double, double)

Return a basic blue vehicle.

 o chaser(double, double, double, Color, Color)

Return a vehicle that chases after chasedColor participants.

 o cruiser(double, double, double, Color)

Return a vehicle colored vehicleColor that moves straight ahead and never turns.

 o display(Graphics)

Display the vehicle using the Graphics.

 o displayBroken(Graphics)

"Erase" the old screen representation by drawing the vehicle in its old location using the background color.

 o getBreakDistance()

Return the maximum distance from this vehicle can be broken (rendered inactive) or from which this vehicle can break other participants.

 o getBreaks()

Return a Vector containing the colors of participants that this vehicle can break.

 o getBrokenBy()

Return a Vector containing the colors of participants that can break this vehicle.

 o getDebugText()

Build and return a String containing execution state for the vehicle

 o getDescription()

Return a string describing this vehicle.

 o getDirection()

Return the direction in which this vehicle is heading.

 o getSpeed()

Return the distance traveled by this vehicle when both wheels move forward.

 o green(double, double, double)

Return a basic green vehicle.

 o hasPointLocation()

Vehicles have single point locations, so answer true.

 o lemming(double, double, double)

Return a lemming vehicle

 o moveForward()

Calculate and save the vehicle's new position assuming that both wheels move.

 o orbiter(double, double, double, Color, Color)

Return a vehicle that orbits participants colored orbitedColor.

 o red(double, double, double)

Return a basic red vehicle.

 o runLeftMotor()

Return whether the motor driving the left wheel will run during this simulation step.

 o runRightMotor()

Return whether the motor driving the right wheel will run during this simulation step.

 o setSpeed(double)

Set the distance this vehicle will move when both wheels move forward.

 o standStill()

Calculate the vehicle's new position should it not move (hint: the position doesn't change.

 o step()

Perform the simulation logic for a single step.

 o turn(double)

Turn the vehicle's direction by angle.

 o turnAngle()

Return the angle in radians that a vehicle will turn when only one of its wheels move.

 o turnLeft()

Turn the vehicle to the left.

 o turnRight()

Turn the vehicle to the right.

 o yellow(double, double, double)

Return a basic yellow vehicle.

Constructors

 o Vehicle
 public Vehicle(double x,
                double y,
                double d,
                Color c,
                VehicleNetwork n)
Return a vehicle at location (x,y), facing in direction d, colored c and driven by network n.

Parameters:
x - double
y - double
d - double
c - java.awt.Color
n - gerken.vehicles.VehicleNetwork

Methods

 o addBreaksColor
 public void addBreaksColor(Color c)

Adds c to the set of participant colors that the vehicle can break. If this vehicle gets close to any other participant colored c, that participant will be rendered inActive and will be removed from the simulation.

Parameters:
c - java.awt.Color
 o addBrokenByColor
 public void addBrokenByColor(Color c)

Adds c to the set of participant colors that can break the vehicle. If this vehicle gets close to any other participant colored c, this vehicle will be rendered inActive and will be removed from the simulation.

Parameters:
c - java.awt.Color
 o blue
 public static Vehicle blue(double x,
                            double y,
                            double d)

Return a basic blue vehicle.

Parameters:
x - double
y - double
d - double
Returns:
gerken.vehicles.Vehicle
 o chaser
 public static Vehicle chaser(double x,
                              double y,
                              double d,
                              Color vehicleColor,
                              Color chasedColor)

Return a vehicle that chases after chasedColor participants.

Parameters:
x - double
y - double
d - double
vehicleColor - java.awt.Color
chasedColor - java.awt.Color
Returns:
gerken.vehicles.Vehicle
 o cruiser
 public static Vehicle cruiser(double x,
                               double y,
                               double d,
                               Color vehicleColor)

Return a vehicle colored vehicleColor that moves straight ahead and never turns.

Parameters:
x - double
y - double
d - double
vehicleColor - java.awt.Color
Returns:
gerken.vehicles.Vehicle
 o display
 public void display(Graphics g)

Display the vehicle using the Graphics. First "erase" the old screen representation by drawing the vehicle in its old location using the background color and then draw the vehicle in its new location using the vehicle's real color.

Parameters:
g - java.awt.Graphics
Overrides:
display in class SimulationParticipant
 o displayBroken
 public void displayBroken(Graphics g)

"Erase" the old screen representation by drawing the vehicle in its old location using the background color. The vehicle is no longer active and will be removed from the scenario.

Parameters:
g - java.awt.Graphics
Overrides:
displayBroken in class SimulationParticipant
 o getBreakDistance
 public double getBreakDistance()

Return the maximum distance from this vehicle can be broken (rendered inactive) or from which this vehicle can break other participants.

Returns:
double
 o getBreaks
 public Vector getBreaks()

Return a Vector containing the colors of participants that this vehicle can break.

Returns:
java.util.Vector
 o getBrokenBy
 public Vector getBrokenBy()

Return a Vector containing the colors of participants that can break this vehicle.

Returns:
java.util.Vector
 o getDebugText
 public String getDebugText()

Build and return a String containing execution state for the vehicle

Returns:
java.lang.String
Overrides:
getDebugText in class SimulationParticipant
 o getDescription
 public String getDescription()

Return a string describing this vehicle.

Returns:
java.lang.String
Overrides:
getDescription in class SimulationParticipant
 o getDirection
 public double getDirection()

Return the direction in which this vehicle is heading. Angles are expressed in radians.

Returns:
double
 o getSpeed
 public double getSpeed()

Return the distance traveled by this vehicle when both wheels move forward.

Returns:
double
 o green
 public static Vehicle green(double x,
                             double y,
                             double d)

Return a basic green vehicle.

Parameters:
x - double
y - double
d - double
Returns:
gerken.vehicles.Vehicle
 o hasPointLocation
 public boolean hasPointLocation()

Vehicles have single point locations, so answer true.

Returns:
boolean
Overrides:
hasPointLocation in class SimulationParticipant
 o lemming
 public static Vehicle lemming(double x,
                               double y,
                               double d)

Return a lemming vehicle

Parameters:
x - double
y - double
d - double
Returns:
gerken.vehicles.Vehicle
 o moveForward
 public void moveForward()

Calculate and save the vehicle's new position assuming that both wheels move.

 o orbiter
 public static Vehicle orbiter(double x,
                               double y,
                               double d,
                               Color vehicleColor,
                               Color orbitedColor)

Return a vehicle that orbits participants colored orbitedColor.

Parameters:
x - double
y - double
d - double
vehicleColor - java.awt.Color
orbitedColor - java.awt.Color
Returns:
gerken.vehicles.Vehicle
 o red
 public static Vehicle red(double x,
                           double y,
                           double d)

Return a basic red vehicle.

Parameters:
x - double
y - double
d - double
Returns:
gerken.vehicles.Vehicle
 o runLeftMotor
 public boolean runLeftMotor()

Return whether the motor driving the left wheel will run during this simulation step.

Returns:
boolean
 o runRightMotor
 public boolean runRightMotor()

Return whether the motor driving the right wheel will run during this simulation step.

Returns:
boolean
 o setSpeed
 public void setSpeed(double value)

Set the distance this vehicle will move when both wheels move forward.

Parameters:
value - double
 o standStill
 public void standStill()

Calculate the vehicle's new position should it not move (hint: the position doesn't change.

 o step
 public void step()

Perform the simulation logic for a single step. After the network processes the light inputs, move the vehicle as appropriate.

Overrides:
step in class SimulationParticipant
 o turn
 public void turn(double angle)

Turn the vehicle's direction by angle. The position of the vehicle does not change.

Parameters:
angle - double
 o turnAngle
 public double turnAngle()

Return the angle in radians that a vehicle will turn when only one of its wheels move.

Returns:
double
 o turnLeft
 public void turnLeft()

Turn the vehicle to the left.

 o turnRight
 public void turnRight()

Turn the vehicle to the right.

 o yellow
 public static Vehicle yellow(double x,
                              double y,
                              double d)

Return a basic yellow vehicle.

Parameters:
x - double
y - double
d - double
Returns:
gerken.vehicles.Vehicle

All Packages  Class Hierarchy  This Package  Previous  Next  Index