November 2024
Intermediate to advanced
300 pages
7h 12m
English
Let’s re-examine the slightly improved matches method:
| | public boolean matches(Criteria criteria) { |
| | score = 0; |
| | |
| | var kill = false; |
| | var anyMatches = false; |
| | for (var criterion: criteria) { |
| | var match = criterion.isMatch(profileAnswerMatching(criterion)); |
| | if (!match && criterion.weight() == REQUIRED) { |
| | kill = true; |
| | } |
| | if (match) { |
| | score += criterion.weight().value(); |
| | } |
| | anyMatches |= match; |
| | } |
| | if (kill) |
| | return false; |
| | |
| | return anyMatches; |
| | } |
Careful reading reveals the following outcomes:
Read now
Unlock full access