You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: exercises/practice/bob/.approaches/if-statements/content.md
+11-11Lines changed: 11 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -45,23 +45,23 @@ This approach simplifies the main method `hey` by breaking down each response co
45
45
46
46
The `input` is trimmed using the `String`[`trim()`][trim] method to remove any leading or trailing whitespace. This helps to accurately detect if the input is empty and should prompt a `"Fine. Be that way!"` response.
47
47
48
-
### **Delegating to Helper Methods**:
49
-
48
+
### Delegating to Helper Methods
49
+
50
50
Each condition is evaluated using the following helper methods:
51
51
52
-
-**`isSilent`**: Checks if the trimmed input has no characters.
53
-
-**`isShouting`**: Checks if the input is all uppercase and contains at least one alphabetic character, indicating shouting.
54
-
-**`isQuestioning`**: Verifies if the trimmed input ends with a question mark.
52
+
1.**`isSilent`**: Checks if the trimmed input has no characters.
53
+
2.**`isShouting`**: Checks if the input is all uppercase and contains at least one alphabetic character, indicating shouting.
54
+
3.**`isQuestioning`**: Verifies if the trimmed input ends with a question mark.
55
55
56
56
This modular approach keeps each condition encapsulated, enhancing code clarity.
57
57
58
-
### **Order of Checks**:
59
-
58
+
### Order of Checks
59
+
60
60
The order of checks within `hey` is important:
61
-
- Silence is evaluated first, as it requires an immediate response.
62
-
- Shouted questions take precedence over individual checks for yelling and asking.
63
-
- Yelling comes next, requiring its response if not combined with a question.
64
-
- Asking (a non-shouted question) is checked afterward.
61
+
1. Silence is evaluated first, as it requires an immediate response.
62
+
2. Shouted questions take precedence over individual checks for shouting and questioning.
63
+
3. Shouting comes next, requiring its response if not combined with a question.
64
+
4. Questioning (a non-shouted question) is checked afterward.
65
65
66
66
This ordering ensures that Bob’s response matches the expected behavior without redundancy.
0 commit comments