Skip to content

Commit

Permalink
refactor code for neatness
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-heppner-ibigroup committed Dec 12, 2023
1 parent a850eaf commit cb69652
Showing 1 changed file with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,14 @@ private Optional<Money> getSeniorFare(
Leg leg
) {
var route = leg.getRoute();
var regularFare = getRegularFare(fareType, rideType, defaultFare, leg);
// Many agencies only provide senior discount if using ORCA
return switch (rideType) {
case COMM_TRANS_LOCAL_SWIFT -> usesOrca(fareType)
? optionalUSD(1.25f)
: getRegularFare(fareType, rideType, defaultFare, leg);
case COMM_TRANS_COMMUTER_EXPRESS -> usesOrca(fareType)
? optionalUSD(2f)
: getRegularFare(fareType, rideType, defaultFare, leg);
case COMM_TRANS_LOCAL_SWIFT -> usesOrca(fareType) ? optionalUSD(1.25f) : regularFare;
case COMM_TRANS_COMMUTER_EXPRESS -> usesOrca(fareType) ? optionalUSD(2f) : regularFare;
case EVERETT_TRANSIT, SKAGIT_TRANSIT, WHATCOM_LOCAL, SKAGIT_LOCAL -> optionalUSD(0.5f);
case KITSAP_TRANSIT_FAST_FERRY_EASTBOUND -> fareType.equals(FareType.electronicSenior) // Kitsap only provide discounted senior fare for orca.
? optionalUSD(1f)
: optionalUSD(2f);
case KC_WATER_TAXI_VASHON_ISLAND -> usesOrca(fareType) ? optionalUSD(3f) : optionalUSD(6.75f);
case KC_WATER_TAXI_WEST_SEATTLE -> usesOrca(fareType)
? optionalUSD(2.5f)
: optionalUSD(5.75f);
case SOUND_TRANSIT,
case KITSAP_TRANSIT_FAST_FERRY_EASTBOUND,
SOUND_TRANSIT,
SOUND_TRANSIT_BUS,
SOUND_TRANSIT_LINK,
SOUND_TRANSIT_SOUNDER,
Expand All @@ -324,10 +316,12 @@ private Optional<Money> getSeniorFare(
SEATTLE_STREET_CAR,
KITSAP_TRANSIT -> fareType.equals(FareType.electronicSenior)
? optionalUSD(1f)
: getRegularFare(fareType, rideType, defaultFare, leg);
: regularFare;
case KC_WATER_TAXI_VASHON_ISLAND -> usesOrca(fareType) ? optionalUSD(3f) : regularFare;
case KC_WATER_TAXI_WEST_SEATTLE -> usesOrca(fareType) ? optionalUSD(2.5f) : regularFare;
case KITSAP_TRANSIT_FAST_FERRY_WESTBOUND -> fareType.equals(FareType.electronicSenior)
? optionalUSD(5f)
: optionalUSD(10f);
: regularFare;
// Discount specific to Skagit transit and not Orca.
case WASHINGTON_STATE_FERRIES -> Optional.of(
getWashingtonStateFerriesFare(route.getLongName(), fareType, defaultFare)
Expand Down

0 comments on commit cb69652

Please sign in to comment.