Compare commits

...

3 Commits

Author SHA1 Message Date
aa5cc9b68b
Added a couple of log events as info 2020-11-27 05:45:00 +03:00
1fa3e4f5f1
log to file 'log.txt' with simple format 2020-11-27 05:33:13 +03:00
2d8456c975
Added logger. Not incomplete. 2020-11-27 05:12:57 +03:00

View File

@ -1,4 +1,8 @@
import java.util.*; import java.util.*;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;
public class MakkahCity { public class MakkahCity {
@ -19,9 +23,22 @@ public class MakkahCity {
); );
private static PDate currenttimeManager = firstDayTimeMan; private static PDate currenttimeManager = firstDayTimeMan;
private static Logger log = Logger.getLogger("MakkahCity");
public static void main(String[] args) { public static void main(String[] args) {
log.setLevel(Level.FINE);
try {
FileHandler fileHandler = new FileHandler("log.txt");
SimpleFormatter f = new SimpleFormatter();
fileHandler.setFormatter(f);
log.addHandler(fileHandler);
log.log(Level.FINE,"File Handler passed");
}
catch (Exception e){
System.err.println("Cant start log");
}
log.log(Level.FINE,"Starting Hajj-simulation");
//Gen Camp //Gen Camp
campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>(); campPerDistrict[District.ALMANSOOR.ordinal()] = new ArrayList<>();
campPerDistrict[District.ALAZIZIYA.ordinal()] = new ArrayList<>(); campPerDistrict[District.ALAZIZIYA.ordinal()] = new ArrayList<>();
@ -30,6 +47,8 @@ public class MakkahCity {
generateCamps(District.ALMANSOOR, (int)getRandom(1600, 1800)); generateCamps(District.ALMANSOOR, (int)getRandom(1600, 1800));
generateCamps(District.ALHIJRA, (int)getRandom(1400, 1600)); generateCamps(District.ALHIJRA, (int)getRandom(1400, 1600));
log.fine(String.format("Generated %d Campaigns", listOfCampaigns.size()));
fillBusesToList(); fillBusesToList();
makeStreets(); makeStreets();
@ -78,6 +97,7 @@ public class MakkahCity {
if (!vehicle.isArrivedToDest()) { if (!vehicle.isArrivedToDest()) {
double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(), double factor = 1-(vehicle.getCurrentStreet().capcityPoint(vehicle.getCurrentLocation(),
vehicle.getCurrentLocation()+1000,vehicle)) ; vehicle.getCurrentLocation()+1000,vehicle)) ;
log.info(String.format("Vehicle %s moving with factor %f on street %s",vehicle, factor, vehicle.getCurrentStreet()));
if (vehicle instanceof Bus) vehicle.move(Bus.MAX_FORWARD * factor ); 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 Sedan) vehicle.move(Sedan.MAX_FORWARD * factor );
else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor ); else if (vehicle instanceof SUV) vehicle.move(SUV.MAX_FORWARD * factor );
@ -423,6 +443,7 @@ public class MakkahCity {
if (r.getTotalLength() < min) { if (r.getTotalLength() < min) {
min = r.getTotalLength(); min = r.getTotalLength();
route = r; route = r;
log.info(String.format("Set Route %s for campaign %s",r , campaign));
} }
} }
} }