Compare commits
2 Commits
master
...
thread-tes
Author | SHA1 | Date | |
---|---|---|---|
6cc0bb434b | |||
d1061221e8 |
@ -21,7 +21,7 @@ public class MakkahCity {
|
||||
private static PDate currenttimeManager = firstDayTimeMan;
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
ArrayList<Thread> threads = new ArrayList<>();
|
||||
//Gen Camp
|
||||
campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>();
|
||||
campPerDistrict[District.ALAZIZIYA.ordinal()] = new ArrayList<>();
|
||||
@ -62,28 +62,10 @@ public class MakkahCity {
|
||||
}
|
||||
clearDoneCivilVehicles();
|
||||
for (Vehicle vehicle : listOfVehicles) {
|
||||
Route route = vehicle.getRoute();
|
||||
double currentLocation = vehicle.getCurrentLocation();
|
||||
if (vehicle.getCurrentStreet() == null &&
|
||||
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
||||
vehicle.setCurrentStreet(route.getStreets()[0]);
|
||||
}
|
||||
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
||||
currentLocation+1000) < 1 ) {
|
||||
|
||||
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
||||
//Move to next street
|
||||
vehicle.moveToNextStreet();
|
||||
}
|
||||
if (!vehicle.isArrivedToDest()) {
|
||||
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
||||
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
||||
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||
}
|
||||
}
|
||||
VMover m = new VMover(vehicle);
|
||||
//threads.add(new Thread(m));
|
||||
Thread t = new Thread(m);
|
||||
t.start();
|
||||
}
|
||||
//noise based on time of day (From PDate)
|
||||
firstDayTimeMan.step(Calendar.MINUTE, 1);
|
||||
|
34
src/VMover.java
Normal file
34
src/VMover.java
Normal file
@ -0,0 +1,34 @@
|
||||
public class VMover implements Runnable {
|
||||
|
||||
private Vehicle vehicle;
|
||||
|
||||
public VMover(Vehicle vehicle) {
|
||||
this.vehicle = vehicle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
Route route = vehicle.getRoute();
|
||||
double currentLocation = vehicle.getCurrentLocation();
|
||||
if (vehicle.getCurrentStreet() == null &&
|
||||
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
||||
vehicle.setCurrentStreet(route.getStreets()[0]);
|
||||
}
|
||||
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
||||
currentLocation+1000) < 1 ) {
|
||||
|
||||
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
||||
//Move to next street
|
||||
vehicle.moveToNextStreet();
|
||||
}
|
||||
if (!vehicle.isArrivedToDest()) {
|
||||
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
|
||||
vehicle.getCurrentLocation()+1000,vehicle)) ;
|
||||
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof Sedan) vehicle.move(Sedan.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
|
||||
else if (vehicle instanceof Truck) vehicle.move(Bus.MAX_FORWARD * factor );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user