Reindent (No Change)
This commit is contained in:
parent
69c1a19ed9
commit
612c00a3f1
@ -17,8 +17,8 @@ public class MakkahCity {
|
|||||||
private static Date allArrivedToHotelsTime;
|
private static Date allArrivedToHotelsTime;
|
||||||
|
|
||||||
private static final PDate firstDayTimeMan = new PDate(
|
private static final PDate firstDayTimeMan = new PDate(
|
||||||
new GregorianCalendar(1442, Calendar.JANUARY, 9, 4, 0, 0),
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 4, 0, 0),
|
||||||
new GregorianCalendar(1442, Calendar.JANUARY, 9, 18, 0, 0)
|
new GregorianCalendar(1442, Calendar.JANUARY, 9, 18, 0, 0)
|
||||||
);
|
);
|
||||||
|
|
||||||
private static final PDate lastDayTimeMan = new PDate(
|
private static final PDate lastDayTimeMan = new PDate(
|
||||||
@ -46,9 +46,9 @@ public class MakkahCity {
|
|||||||
private static JLabel lblNumOfDonebuses;
|
private static JLabel lblNumOfDonebuses;
|
||||||
private static JLabel lblMaximumTripValue;
|
private static JLabel lblMaximumTripValue;
|
||||||
private static JLabel lblMinimumTripValue;
|
private static JLabel lblMinimumTripValue;
|
||||||
private static JLabel lblBusesArrivedInTheLastHourValue;
|
private static JLabel lblBusesArrivedInTheLastHourValue;
|
||||||
private static JLabel lblAverageTripForLastHourValue;
|
private static JLabel lblAverageTripForLastHourValue;
|
||||||
private static JButton btnPause;
|
private static JButton btnPause;
|
||||||
private static JLabel lblAverageTimeForTheTrip;
|
private static JLabel lblAverageTimeForTheTrip;
|
||||||
private static JLabel lblArrivedToArafatTime;
|
private static JLabel lblArrivedToArafatTime;
|
||||||
private static JLabel lblArrivedToHotelsTime;
|
private static JLabel lblArrivedToHotelsTime;
|
||||||
@ -443,11 +443,11 @@ public class MakkahCity {
|
|||||||
Route route = vehicle.getRoute();
|
Route route = vehicle.getRoute();
|
||||||
double currentLocation = vehicle.getCurrentLocation();
|
double currentLocation = vehicle.getCurrentLocation();
|
||||||
if (vehicle.getCurrentStreet() == null &&
|
if (vehicle.getCurrentStreet() == null &&
|
||||||
firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 2 == 0 &&
|
firstDayTimeMan.getCurrentCalendar().get(Calendar.MINUTE) % 2 == 0 &&
|
||||||
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
route.getStreets()[0].capcityPoint(0,1000) < 1) {
|
||||||
vehicle.setCurrentStreet(route.getStreets()[0]);
|
vehicle.setCurrentStreet(route.getStreets()[0]);
|
||||||
}
|
}
|
||||||
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
if (vehicle.getCurrentStreet() != null && vehicle.getCurrentStreet().capcityPoint(currentLocation,
|
||||||
currentLocation+1000) < 1 ) {
|
currentLocation+1000) < 1 ) {
|
||||||
|
|
||||||
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
if (currentLocation >= vehicle.getCurrentStreet().getLength()) {
|
||||||
@ -456,7 +456,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)) ;
|
||||||
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 );
|
||||||
@ -564,15 +564,15 @@ public class MakkahCity {
|
|||||||
private static void startMenu() {
|
private static void startMenu() {
|
||||||
Scanner in = new Scanner(System.in);
|
Scanner in = new Scanner(System.in);
|
||||||
System.out.println("\n"+currenttimeManager.getCurrentTime()+"\n"+
|
System.out.println("\n"+currenttimeManager.getCurrentTime()+"\n"+
|
||||||
"---------------------------\n" +
|
"---------------------------\n" +
|
||||||
"[1] View Buses\n" +
|
"[1] View Buses\n" +
|
||||||
"[2] View Streets\n" +
|
"[2] View Streets\n" +
|
||||||
"[3] View Campaigns\n" +
|
"[3] View Campaigns\n" +
|
||||||
"[4] View Routes\n" +
|
"[4] View Routes\n" +
|
||||||
"[5] Print report\n" +
|
"[5] Print report\n" +
|
||||||
"[6] Browse History\n" +
|
"[6] Browse History\n" +
|
||||||
"[7] Continue\n" +
|
"[7] Continue\n" +
|
||||||
"[8] Exit");
|
"[8] Exit");
|
||||||
String choice = in.next();
|
String choice = in.next();
|
||||||
//Split into methods?
|
//Split into methods?
|
||||||
if (choice.equals("1")){
|
if (choice.equals("1")){
|
||||||
@ -694,9 +694,9 @@ public class MakkahCity {
|
|||||||
while (!selected){
|
while (!selected){
|
||||||
System.out.println(new HijriDate(dummyCal.getTimeInMillis()));
|
System.out.println(new HijriDate(dummyCal.getTimeInMillis()));
|
||||||
System.out.print("[1] Forward\n" +
|
System.out.print("[1] Forward\n" +
|
||||||
"[2] Backward\n" +
|
"[2] Backward\n" +
|
||||||
"[3] Select\n" +
|
"[3] Select\n" +
|
||||||
"[4] Return\n");
|
"[4] Return\n");
|
||||||
String choice = in.next();
|
String choice = in.next();
|
||||||
if (choice.equals("1")) dummyCal.roll(Calendar.HOUR, 1);
|
if (choice.equals("1")) dummyCal.roll(Calendar.HOUR, 1);
|
||||||
if (choice.equals("2")) dummyCal.roll(Calendar.HOUR, -1);
|
if (choice.equals("2")) dummyCal.roll(Calendar.HOUR, -1);
|
||||||
@ -783,9 +783,9 @@ public class MakkahCity {
|
|||||||
District.ALHIJRA, Mashier.ARAFAT);
|
District.ALHIJRA, Mashier.ARAFAT);
|
||||||
|
|
||||||
stdRoutes[RouteName.AlHijraToArafat2.ordinal()] = new Route(new Street[]{
|
stdRoutes[RouteName.AlHijraToArafat2.ordinal()] = new Route(new Street[]{
|
||||||
stdStreet[StreetNames.JABAL_THAWR_STREET.ordinal()],
|
stdStreet[StreetNames.JABAL_THAWR_STREET.ordinal()],
|
||||||
stdStreet[StreetNames.FOURTH_HIGHWAY2.ordinal()],
|
stdStreet[StreetNames.FOURTH_HIGHWAY2.ordinal()],
|
||||||
stdStreet[StreetNames.STREET1.ordinal()]
|
stdStreet[StreetNames.STREET1.ordinal()]
|
||||||
},District.ALHIJRA, Mashier.ARAFAT);
|
},District.ALHIJRA, Mashier.ARAFAT);
|
||||||
|
|
||||||
stdRoutes[RouteName.AlMansoorToArafat1.ordinal()] = new Route(
|
stdRoutes[RouteName.AlMansoorToArafat1.ordinal()] = new Route(
|
||||||
@ -819,7 +819,7 @@ public class MakkahCity {
|
|||||||
stdStreet[StreetNames.KA_STREET.ordinal()],
|
stdStreet[StreetNames.KA_STREET.ordinal()],
|
||||||
stdStreet[StreetNames.STREET2.ordinal()],
|
stdStreet[StreetNames.STREET2.ordinal()],
|
||||||
stdStreet[StreetNames.STREET1.ordinal()]
|
stdStreet[StreetNames.STREET1.ordinal()]
|
||||||
},District.ALAZIZIYA, Mashier.ARAFAT);
|
},District.ALAZIZIYA, Mashier.ARAFAT);
|
||||||
|
|
||||||
//******Arafat day end
|
//******Arafat day end
|
||||||
|
|
||||||
@ -1032,8 +1032,8 @@ public class MakkahCity {
|
|||||||
if (currenttimeManager == firstDayTimeMan) status = " Status: Heading to Arafat";
|
if (currenttimeManager == firstDayTimeMan) status = " Status: Heading to Arafat";
|
||||||
else status = " Status: Heading to hotels";
|
else status = " Status: Heading to hotels";
|
||||||
String headerFormat = "******Streets report*****\n" +
|
String headerFormat = "******Streets report*****\n" +
|
||||||
"Time: %s%s\n" +
|
"Time: %s%s\n" +
|
||||||
" Street name |Street Load| Total | Buses | Local Vehicles | Avg. Time |\n";
|
" Street name |Street Load| Total | Buses | Local Vehicles | Avg. Time |\n";
|
||||||
|
|
||||||
StringBuilder report = new StringBuilder();
|
StringBuilder report = new StringBuilder();
|
||||||
report.append(String.format(headerFormat, currenttimeManager.getCurrentTime(), status));
|
report.append(String.format(headerFormat, currenttimeManager.getCurrentTime(), status));
|
||||||
@ -1079,7 +1079,7 @@ public class MakkahCity {
|
|||||||
if (Vehicle.getMaxArrived() != null && Vehicle.getMinArrived() != null) {
|
if (Vehicle.getMaxArrived() != null && Vehicle.getMinArrived() != null) {
|
||||||
report.append(String.format(" Maximum trip %s,", Vehicle.getMaxArrived().timeToString()));
|
report.append(String.format(" Maximum trip %s,", Vehicle.getMaxArrived().timeToString()));
|
||||||
report.append(String.format(" Minimum trip %s", Vehicle.getMinArrived().timeToString()));
|
report.append(String.format(" Minimum trip %s", Vehicle.getMinArrived().timeToString()));
|
||||||
}
|
}
|
||||||
return report.toString();
|
return report.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1097,7 +1097,7 @@ public class MakkahCity {
|
|||||||
for (Campaign campaign : listOfCampaigns){
|
for (Campaign campaign : listOfCampaigns){
|
||||||
for (Vehicle bus : campaign.getVehicles()){
|
for (Vehicle bus : campaign.getVehicles()){
|
||||||
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
||||||
&& bus.getTimeOfArrival().after(from.getTime())) {
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
||||||
long minutes = (bus.getTimeOfArrival().getTime() - bus.getTimeStartedMoving().getTime())/60000;
|
long minutes = (bus.getTimeOfArrival().getTime() - bus.getTimeStartedMoving().getTime())/60000;
|
||||||
sum+= minutes;
|
sum+= minutes;
|
||||||
counter++;
|
counter++;
|
||||||
@ -1143,7 +1143,7 @@ public class MakkahCity {
|
|||||||
for (Campaign campaign : listOfCampaigns) {
|
for (Campaign campaign : listOfCampaigns) {
|
||||||
for (Vehicle vehicle : campaign.getVehicles()){
|
for (Vehicle vehicle : campaign.getVehicles()){
|
||||||
if (vehicle instanceof Bus &&
|
if (vehicle instanceof Bus &&
|
||||||
vehicle.isArrivedToDest()) num++;
|
vehicle.isArrivedToDest()) num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
@ -1157,7 +1157,7 @@ public class MakkahCity {
|
|||||||
for (Campaign campaign : listOfCampaigns){
|
for (Campaign campaign : listOfCampaigns){
|
||||||
for (Vehicle bus : campaign.getVehicles()){
|
for (Vehicle bus : campaign.getVehicles()){
|
||||||
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
if (bus.isArrivedToDest() && bus.getTimeOfArrival().before(now.getTime())
|
||||||
&& bus.getTimeOfArrival().after(from.getTime())) {
|
&& bus.getTimeOfArrival().after(from.getTime())) {
|
||||||
num++;
|
num++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1234,7 +1234,7 @@ public class MakkahCity {
|
|||||||
if (!result) System.out.println("Could not save state "+currenttimeManager.getCurrentTime().getTime());
|
if (!result) System.out.println("Could not save state "+currenttimeManager.getCurrentTime().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void updateStreetFrame() {
|
private static void updateStreetFrame() {
|
||||||
Object[][] streetData = new Object[stdStreet.length][6];
|
Object[][] streetData = new Object[stdStreet.length][6];
|
||||||
for (int i = 0; i < stdStreet.length; i++) {
|
for (int i = 0; i < stdStreet.length; i++) {
|
||||||
streetData[i][0] = stdStreet[i].getName().name();
|
streetData[i][0] = stdStreet[i].getName().name();
|
||||||
@ -1268,28 +1268,28 @@ public class MakkahCity {
|
|||||||
if (lblArrivedToArafatTime.getText().equalsIgnoreCase("N/A"))
|
if (lblArrivedToArafatTime.getText().equalsIgnoreCase("N/A"))
|
||||||
if (allArrivedToArafatTime != null) {
|
if (allArrivedToArafatTime != null) {
|
||||||
lblArrivedToArafatTime.setText(allArrivedToArafatTime.toString());
|
lblArrivedToArafatTime.setText(allArrivedToArafatTime.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lblArrivedToHotelsTime.getText().equalsIgnoreCase("N/A"))
|
if (lblArrivedToHotelsTime.getText().equalsIgnoreCase("N/A"))
|
||||||
if (allArrivedToHotelsTime != null) {
|
if (allArrivedToHotelsTime != null) {
|
||||||
lblArrivedToHotelsTime.setText(allArrivedToHotelsTime.toString());
|
lblArrivedToHotelsTime.setText(allArrivedToHotelsTime.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
String status = "";
|
||||||
|
if (currenttimeManager == firstDayTimeMan) {
|
||||||
|
status = "Heading to Arafat";
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
status = "Heading to Hotels";
|
||||||
|
}
|
||||||
|
lblDestination.setText(status);
|
||||||
|
|
||||||
String status = "";
|
int numberOfBusses = 0;
|
||||||
if (currenttimeManager == firstDayTimeMan) {
|
for (Campaign campaign : listOfCampaigns) {
|
||||||
status = "Heading to Arafat";
|
numberOfBusses += campaign.getNumberOfBusses();
|
||||||
}
|
}
|
||||||
else{
|
String bus = String.format("%d", numberOfBusses);
|
||||||
status = "Heading to Hotels";
|
lblNumOfBuses.setText(bus);
|
||||||
}
|
|
||||||
lblDestination.setText(status);
|
|
||||||
|
|
||||||
int numberOfBusses = 0;
|
|
||||||
for (Campaign campaign : listOfCampaigns) {
|
|
||||||
numberOfBusses += campaign.getNumberOfBusses();
|
|
||||||
}
|
|
||||||
String bus = String.format("%d", numberOfBusses);
|
|
||||||
lblNumOfBuses.setText(bus);
|
|
||||||
|
|
||||||
String numOfdoneBuses = String.format("%d",getNumberOfArrivedBusses());
|
String numOfdoneBuses = String.format("%d",getNumberOfArrivedBusses());
|
||||||
lblNumOfDonebuses.setText(numOfdoneBuses);
|
lblNumOfDonebuses.setText(numOfdoneBuses);
|
||||||
@ -1305,44 +1305,44 @@ public class MakkahCity {
|
|||||||
lblAverageTripForLastHourValue.setText(avgTimeOfTrip());
|
lblAverageTripForLastHourValue.setText(avgTimeOfTrip());
|
||||||
lblAverageTimeForTheTrip.setText(getAvgTripForAllDis());
|
lblAverageTimeForTheTrip.setText(getAvgTripForAllDis());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getAvgTripForAllDis() {
|
public static String getAvgTripForAllDis() {
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int counter = 1;
|
int counter = 1;
|
||||||
for (Campaign campaign : listOfCampaigns) {
|
for (Campaign campaign : listOfCampaigns) {
|
||||||
for (Vehicle vehicle : campaign.getVehicles()) {
|
for (Vehicle vehicle : campaign.getVehicles()) {
|
||||||
if (vehicle.isArrivedToDest()) {
|
if (vehicle.isArrivedToDest()) {
|
||||||
long minutes = (vehicle.getTimeOfArrival().getTime() - vehicle.getTimeStartedMoving().getTime())/60000;
|
long minutes = (vehicle.getTimeOfArrival().getTime() - vehicle.getTimeStartedMoving().getTime())/60000;
|
||||||
sum+= minutes;
|
sum+= minutes;
|
||||||
counter++;
|
counter++;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}//Make the following a method since it is the same other method
|
|
||||||
sum = sum /counter;
|
|
||||||
int hours = sum / 60;
|
|
||||||
int minutes = sum % 60;
|
|
||||||
if (hours == 0 && minutes == 0) return "-:--";
|
|
||||||
return String.format("%2d:%02d", hours,minutes);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getDistTimeForLbl() {
|
|
||||||
int numberOfBusses = 0;
|
|
||||||
int numberOfArrivedBuses = getNumberOfArrivedBusses();
|
|
||||||
|
|
||||||
for (Campaign campaign : listOfCampaigns) {
|
|
||||||
numberOfBusses += campaign.getNumberOfBusses();
|
|
||||||
}
|
}
|
||||||
|
}//Make the following a method since it is the same other method
|
||||||
|
sum = sum /counter;
|
||||||
|
int hours = sum / 60;
|
||||||
|
int minutes = sum % 60;
|
||||||
|
if (hours == 0 && minutes == 0) return "-:--";
|
||||||
|
return String.format("%2d:%02d", hours,minutes);
|
||||||
|
}
|
||||||
|
|
||||||
boolean Done = isAllArrived();
|
private static String getDistTimeForLbl() {
|
||||||
if (Done && allArrivedToArafatTime != null) {
|
int numberOfBusses = 0;
|
||||||
return String.format("%s", allArrivedToArafatTime);
|
int numberOfArrivedBuses = getNumberOfArrivedBusses();
|
||||||
}
|
|
||||||
if (Done && allArrivedToHotelsTime != null) {
|
for (Campaign campaign : listOfCampaigns) {
|
||||||
return String.format("%s",allArrivedToHotelsTime);
|
numberOfBusses += campaign.getNumberOfBusses();
|
||||||
}
|
}
|
||||||
return "N/A";
|
|
||||||
}
|
boolean Done = isAllArrived();
|
||||||
|
if (Done && allArrivedToArafatTime != null) {
|
||||||
|
return String.format("%s", allArrivedToArafatTime);
|
||||||
|
}
|
||||||
|
if (Done && allArrivedToHotelsTime != null) {
|
||||||
|
return String.format("%s",allArrivedToHotelsTime);
|
||||||
|
}
|
||||||
|
return "N/A";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user