Compare commits
3 Commits
bffcddf6e2
...
58054d6eea
Author | SHA1 | Date | |
---|---|---|---|
|
58054d6eea | ||
|
b2bc60394a | ||
|
a3dd3b6585 |
@ -1,11 +1,13 @@
|
|||||||
package de.hems.trafficsim;
|
package de.hems.trafficsim;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
|
|
||||||
public class Track extends Observable {
|
public class Track extends Observable {
|
||||||
protected List<Vehicle> vehicles;
|
protected List<Vehicle> vehicles;
|
||||||
|
protected List<List<VehicleTimeRecord>> vtr_list;
|
||||||
protected float trackLength;
|
protected float trackLength;
|
||||||
|
|
||||||
public List<Vehicle> getVehicles() {
|
public List<Vehicle> getVehicles() {
|
||||||
@ -19,7 +21,7 @@ public class Track extends Observable {
|
|||||||
public Track(int numberVehicles, float trackLength) {
|
public Track(int numberVehicles, float trackLength) {
|
||||||
this.trackLength = trackLength;
|
this.trackLength = trackLength;
|
||||||
this.vehicles = createVehiclesList(numberVehicles);
|
this.vehicles = createVehiclesList(numberVehicles);
|
||||||
|
this.vtr_list = new LinkedList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<Vehicle> createVehiclesList(int numberVehicles){
|
protected List<Vehicle> createVehiclesList(int numberVehicles){
|
||||||
@ -46,9 +48,12 @@ public class Track extends Observable {
|
|||||||
}
|
}
|
||||||
v.updateVelocity(distanceForerunner);
|
v.updateVelocity(distanceForerunner);
|
||||||
}
|
}
|
||||||
|
List <VehicleTimeRecord> records = new ArrayList<>(vehicles.size());
|
||||||
|
this.vtr_list.add(records);
|
||||||
for(Vehicle v: vehicles){
|
for(Vehicle v: vehicles){
|
||||||
v.timeElapse(50);
|
v.timeElapse(50);
|
||||||
|
VehicleTimeRecord vtr = new VehicleTimeRecord(v.id, v.position, v.curVelocity, timeStep);
|
||||||
|
records.add(vtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setChanged();
|
this.setChanged();
|
||||||
|
@ -13,12 +13,14 @@ public class VehicleTimeRecord {
|
|||||||
return timestep;
|
return timestep;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int id;
|
||||||
protected float position;
|
protected float position;
|
||||||
protected float velocity;
|
protected float velocity;
|
||||||
protected float timestep;
|
protected float timestep;
|
||||||
|
|
||||||
public VehicleTimeRecord(float position, float velocity, float timestep) {
|
public VehicleTimeRecord(int id, float position, float velocity, float timestep) {
|
||||||
this.position = position;
|
this.id = id;
|
||||||
|
this.position = position; //needed???
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.timestep = timestep;
|
this.timestep = timestep;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user