Compare commits
No commits in common. "58054d6eea47989c8b44e02b8d3b077541775dd2" and "bffcddf6e2c55fbcb71b880720dc0464410ed8e4" have entirely different histories.
58054d6eea
...
bffcddf6e2
@ -1,13 +1,11 @@
|
|||||||
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() {
|
||||||
@ -21,7 +19,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){
|
||||||
@ -48,12 +46,9 @@ 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,14 +13,12 @@ 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(int id, float position, float velocity, float timestep) {
|
public VehicleTimeRecord(float position, float velocity, float timestep) {
|
||||||
this.id = id;
|
this.position = position;
|
||||||
this.position = position; //needed???
|
|
||||||
this.velocity = velocity;
|
this.velocity = velocity;
|
||||||
this.timestep = timestep;
|
this.timestep = timestep;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user