Skip to content

Vehicle.java

Raphael Lutz edited this page Aug 19, 2018 · 2 revisions

Represents the vehicles of the simulation

Fields

  • static int idCounter = 1 : a counter on the IDs of the vehicle, static field.
  • int id : the ID of the current vehicle, set on the static counter.
  • Cell cell : current cell on which is the vehicle.
  • Cell nextPlace : the next cell where the vehicle will go after one step.
  • int speed = 1 : the current speed of the vehicle.
  • boolean hasToLeave = false : tells if the vehicle has to leave the network.

Methods

  • Vehicle() : the constructor of the class.
  • void evolve() : update the current location cell with the new one nextPlace.
  • void leaveNetwork() : called if the vehicle has to leave the Network.
  • void stayHere() : called if the vehicle must stay at its location.
  • void goToNextCell() : called if the vehicle has to go to the nextCell of its location.
  • void goToOutCell() : called if the vehicle has to go to the outCell of its location.
  • void accelerate() : accelerate the vehicle by 1 unit.
  • void decelerate() : accelerate the vehicle by 1 unit.

Getters and setters

Getters and setters for some of the fields.

Clone this wiki locally