Min/Max for history

This commit is contained in:
HeshamTB 2020-12-18 14:57:06 +03:00
parent c07dc8a87c
commit f137b07c1e
2 changed files with 23 additions and 7 deletions

View File

@ -106,6 +106,8 @@ class State implements Serializable {
private Date allArrivedToArafatTime; private Date allArrivedToArafatTime;
private Date allArrivedToHotelsTime; private Date allArrivedToHotelsTime;
private Date stateTime; private Date stateTime;
private String maxTrip;
private String minTrip;
public State(ArrayList<Campaign> listOfCampaigns, public State(ArrayList<Campaign> listOfCampaigns,
ArrayList<Vehicle> listOfVehicles, ArrayList<Vehicle> listOfVehicles,
@ -128,6 +130,14 @@ class State implements Serializable {
this.allArrivedToHotelsTime = (Date) allArrivedToHotelsTime.clone(); this.allArrivedToHotelsTime = (Date) allArrivedToHotelsTime.clone();
} }
this.stateTime = stateTime; this.stateTime = stateTime;
if (Vehicle.getMinArrived() != null && Vehicle.getMaxArrived() != null){
this.maxTrip = Vehicle.getMaxArrived().getTripTime();
this.minTrip = Vehicle.getMinArrived().getTripTime();
}
else {
this.maxTrip = "N/A";
this.minTrip = "N/A";
}
} }
public ArrayList<Campaign> getListOfCampaigns() { public ArrayList<Campaign> getListOfCampaigns() {
@ -162,4 +172,11 @@ class State implements Serializable {
return stateTime; return stateTime;
} }
public String getMaxTrip() {
return maxTrip;
}
public String getMinTrip() {
return minTrip;
}
} }

View File

@ -16,6 +16,7 @@ import java.awt.SystemColor;
public class GUI_History { public class GUI_History {
private List<State> states; private List<State> states;
private State selectedState;
private ArrayList<Campaign> listOfCampaigns; private ArrayList<Campaign> listOfCampaigns;
private ArrayList<Vehicle> listOfVehicles; private ArrayList<Vehicle> listOfVehicles;
private ArrayList<Campaign>[] campPerDistrict; private ArrayList<Campaign>[] campPerDistrict;
@ -302,6 +303,7 @@ public class GUI_History {
stdRoutes = state.getStdRoutes(); stdRoutes = state.getStdRoutes();
stdStreet = state.getStdStreet(); stdStreet = state.getStdStreet();
currenttimeManager = state.getStateTime(); currenttimeManager = state.getStateTime();
selectedState = state;
} }
public void updateFrame() { public void updateFrame() {
@ -348,16 +350,13 @@ public class GUI_History {
String numOfdoneBuses = String.format("%d", getNumberOfArrivedBusses()); String numOfdoneBuses = String.format("%d", getNumberOfArrivedBusses());
lblNumOfDonebuses.setText(numOfdoneBuses); lblNumOfDonebuses.setText(numOfdoneBuses);
if (Vehicle.getMaxArrived() != null && Vehicle.getMinArrived() != null) {
lblMaximumTripValue.setText(Vehicle.getMaxArrived().getTripTime().toString());
lblMinimumTripValue.setText(Vehicle.getMinArrived().getTripTime().toString());
}
String NumberOfBussPerHour = String.format("%d", getNumberOfArrivedBussesPerHour()); String NumberOfBussPerHour = String.format("%d", getNumberOfArrivedBussesPerHour());
lblBusesArrivedInTheLastHourValue.setText(NumberOfBussPerHour); lblBusesArrivedInTheLastHourValue.setText(NumberOfBussPerHour);
lblAverageTripForLastHourValue.setText(avgTimeOfTrip()); lblAverageTripForLastHourValue.setText(avgTimeOfTrip());
lblAverageTimeForTheTrip.setText(getAvgTripForAllDis()); lblAverageTimeForTheTrip.setText(getAvgTripForAllDis());
lblMaximumTripValue.setText(selectedState.getMaxTrip());
lblMinimumTripValue.setText(selectedState.getMinTrip());
} }
//Methods //Methods