Skip to content

Commit 3ae61e1

Browse files
Merge pull request #22 from stephengoldbaum/master
Added more cases to the conditions decision table
2 parents 1bf0240 + 02b1029 commit 3ae61e1

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

tutorial/step_2_business_language/src/Morphir/Example/App/Rentals.elm

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,29 @@ import Morphir.Example.App.Winds exposing (..)
88
decide : WindCategory -> ForecastDetail -> CurrentInventory -> ProbableReservations -> PendingReturns -> RequestedQuantity -> AllowPartials -> Result Reason ReservationQuantity
99
decide windCategory forecastDetail inventory probableReservations returns requestedQuantity allowPartials =
1010
let
11-
isClosed : Bool
12-
isClosed = (windCategory == DangerousWinds) || (forecastDetail == Thunderstorms)
11+
safeConditions : Bool
12+
safeConditions =
13+
case ( windCategory, forecastDetail ) of
14+
( DangerousWinds, _ ) ->
15+
False
16+
17+
( _, Thunderstorms ) ->
18+
False
19+
20+
( HighWinds, Snow ) ->
21+
False
22+
23+
( HighWinds, Fog ) ->
24+
False
25+
26+
_ ->
27+
True
1328

1429
availability : Availability
1530
availability =
1631
inventory - probableReservations + returns
1732
in
18-
if isClosed then
33+
if not safeConditions then
1934
Err ClosedDueToConditions
2035

2136
else if availability == 0 then

tutorial/step_2_business_language/src/Morphir/Example/App/Winds.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ categorizeWind windSpeed =
1010
Calm
1111

1212
else if windSpeed < 20 then
13-
HighWinds
13+
Windy
1414

1515
else if windSpeed < 30 then
16-
Windy
16+
HighWinds
1717

1818
else
1919
DangerousWinds

0 commit comments

Comments
 (0)