Overview
This article shows the design pattern of using linked generators with the CaseActionGen Generator to take a specific action determined by the first case that returns true.
Example
Determine the mode of a user's transportation based on the random case the falls into:
- if case 1 is true, then take a Car
- if case 2 is true, then take a Train
- if case 3 is true, then take a Plane
- else Walk
Generation Sequence From Left To Right
- Randomly generate a true or false value.
- Randomly generate a true or false value.
- Randomly generate a true or false value.
- Chose a final result based on the precedence of which case is true or choose the default case if none are true.
Video Example
Step by Step Example
1. Create a Domain called "Example"
2. Add an Attribute named "Transportation" to the Example Domain
3. Add the BooleanValueGen to the Transportation Attribute
4. In the "Linked Generators" section, click the "Add Generator" button to add two more BooleanValueGens
4. Provide an alias to each Generator by clicking the pen icon in the "Alias" column. Have the aliases be: case1, case2, and case3.
4. Click the "Add Generator" button and add the CaseActionGen. Give it the alias "action".
5. For the action Generator, give it the default value of "Walk"
6. Add each of the case Generators to the caseList
- Double click the input field
- Select the "Attribute" tab
- Select the case1 Generator
- repeat steps 1-3 until all 3 case Generators are added
7. In the actionList input the following and click "Save Generator":
- Car
- Train
- Plane
7. To see a preview of the data click the "Preview" tab above the Generator parameters
8. Your preview data should have the following rules:
- If case1 is true the action will be Car
- If case1 is false and case2 is true the action will be Train
- if case1 and case2 are false and case3 is true the action will be Plane
- If case1, case2, and case3 are false the action will be Walk