diff --git a/src/DataManeger.java b/src/DataManeger.java index 90378a9..7c236b9 100644 --- a/src/DataManeger.java +++ b/src/DataManeger.java @@ -106,6 +106,8 @@ class State implements Serializable { private Date allArrivedToArafatTime; private Date allArrivedToHotelsTime; private Date stateTime; + private String maxTrip; + private String minTrip; public State(ArrayList listOfCampaigns, ArrayList listOfVehicles, @@ -128,6 +130,14 @@ class State implements Serializable { this.allArrivedToHotelsTime = (Date) allArrivedToHotelsTime.clone(); } 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 getListOfCampaigns() { @@ -161,5 +171,12 @@ class State implements Serializable { public Date getStateTime() { return stateTime; } - + + public String getMaxTrip() { + return maxTrip; + } + + public String getMinTrip() { + return minTrip; + } } diff --git a/src/GUI_History.java b/src/GUI_History.java index c7459c7..4466b2b 100644 --- a/src/GUI_History.java +++ b/src/GUI_History.java @@ -16,6 +16,7 @@ import java.awt.SystemColor; public class GUI_History { private List states; + private State selectedState; private ArrayList listOfCampaigns; private ArrayList listOfVehicles; private ArrayList[] campPerDistrict; @@ -39,7 +40,7 @@ public class GUI_History { "Local Vehicles","Avg. Time"}; private String[] districtColNames = {"District", "Campaigns", "Busses", "Arrival %", "Avg. Time", "Best time to Arafat", "Best time to District"}; - + public GUI_History(List states) { this.states = states; makeFrame(); @@ -302,6 +303,7 @@ public class GUI_History { stdRoutes = state.getStdRoutes(); stdStreet = state.getStdStreet(); currenttimeManager = state.getStateTime(); + selectedState = state; } public void updateFrame() { @@ -348,16 +350,13 @@ public class GUI_History { String numOfdoneBuses = String.format("%d", getNumberOfArrivedBusses()); 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()); lblBusesArrivedInTheLastHourValue.setText(NumberOfBussPerHour); lblAverageTripForLastHourValue.setText(avgTimeOfTrip()); lblAverageTimeForTheTrip.setText(getAvgTripForAllDis()); + lblMaximumTripValue.setText(selectedState.getMaxTrip()); + lblMinimumTripValue.setText(selectedState.getMinTrip()); } //Methods