Skip to content

Commit

Permalink
Merge pull request #353 from HSLdevcom/DT-4576
Browse files Browse the repository at this point in the history
Don't allow pickup or dropoff from stations that are not on
  • Loading branch information
vesameskanen authored Apr 16, 2021
2 parents 4edabc8 + 7288ea4 commit 7b5e0ab
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ protected State traverseRent(State state) {
return null;

BikeRentalStationVertex dropoff = (BikeRentalStationVertex) tov;

/*
* Can't rent a bike from a station that is not on
*/
if (!dropoff.isStationOn()) {
return null;
}

if (options.useBikeRentalAvailabilityInformation && dropoff.getBikesAvailable() == 0)
return null;

Expand Down Expand Up @@ -92,6 +100,14 @@ protected State traverseDropoff(State state) {
return null;

BikeRentalStationVertex pickup = (BikeRentalStationVertex) tov;

/*
* Can't return a bike to a station that is not on
*/
if (!pickup.isStationOn()) {
return null;
}

if (options.useBikeRentalAvailabilityInformation && pickup.getSpacesAvailable() == 0 && !pickup.getAllowOverloading())
return null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ public class BikeRentalStationVertex extends Vertex {

private boolean allowOverloading;

private boolean stationOn = true;

private String id;

/** Some car rental systems and flex transit systems work exactly like bike rental, but with cars. */
Expand All @@ -38,7 +40,8 @@ public BikeRentalStationVertex(Graph g, BikeRentalStation station) {
this.setId(station.id);
this.setBikesAvailable(station.bikesAvailable);
this.setSpacesAvailable(station.spacesAvailable);
this.setAllowOverloading(station.allowOverloading);
this.setAllowOverloading(station.allowOverloading);
this.setStationStatus(station.state);
this.isCarStation = station.isCarStation;
this.station = station;
}
Expand All @@ -55,6 +58,10 @@ public boolean getAllowOverloading() {
return allowOverloading;
}

public boolean isStationOn() {
return stationOn;
}

public void setBikesAvailable(int bikes) {
this.bikesAvailable = bikes;
}
Expand All @@ -67,6 +74,10 @@ public void setAllowOverloading(boolean allowOverloading) {
this.allowOverloading = allowOverloading;
}

public void setStationStatus(String state) {
this.stationOn = state.equals("Station on");
}

public String getId() {
return id;
}
Expand Down

0 comments on commit 7b5e0ab

Please sign in to comment.