Reindent (No Change)

This commit is contained in:
HeshamTB 2021-01-10 22:00:25 +03:00
parent 69c1a19ed9
commit 612c00a3f1

View File

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