did#1408
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your submission has critical issues that must be fixed: 1) Compilation error at line 26 in src/main/java/practice/StreamPractice.java - stream.min() requires a Comparator argument but is called without one. 2) 4 of 6 tasks are not implemented, returning Collections.emptyList() stubs: selectMenByAge, getWorkablePeople, getCatsNames, and validateCandidates. 3) Missing CandidateValidator class implementing Predicate with required validation rules (age ≥35, can vote, nationality "Ukrainian", 10 years in Ukraine via periodsInUkr parsing). 4) Minor issue: Task 2 uses a generic "Wrong number" exception message instead of a descriptive one. Please fix the compilation error and implement the remaining 4 tasks to complete the assignment.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
There are 2 explicit checklist violations that need to be addressed: (1) Enum comparison using '==' instead of 'equals()' in StreamPractice.java, lines 55, 73, and 86; (2) Magic numbers/strings instead of constants in CandidateValidator.java, where hardcoded values 35, "Ukrainian", and 10 should be extracted as named constants MIN_AGE, REQUIRED_NATIONALITY, and MIN_YEARS_IN_UKRAINE for better readability and maintainability.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| public List<Person> selectMenByAge(List<Person> peopleList, int fromAge, int toAge) { | ||
| return Collections.emptyList(); | ||
| return peopleList.stream() | ||
| .filter(p -> p.getSex() == Person.Sex.MAN |
There was a problem hiding this comment.
Checklist item #4 violation: Use equals() for comparing Enum values, not ==. Replace with .equals(Person.Sex.MAN)
| int maleToAge, List<Person> peopleList) { | ||
| return Collections.emptyList(); | ||
| return peopleList.stream() | ||
| .filter(p -> p.getSex() == Person.Sex.MAN |
There was a problem hiding this comment.
Checklist item #4 violation: Use equals() for comparing Enum values, not ==. Replace with .equals(Person.Sex.MAN)
| public List<String> getCatsNames(List<Person> peopleList, int femaleAge) { | ||
| return Collections.emptyList(); | ||
| return peopleList.stream() | ||
| .filter(p -> p.getSex() == Person.Sex.WOMAN && p.getAge() >= femaleAge) |
There was a problem hiding this comment.
Checklist item #4 violation: Use equals() for comparing Enum values, not ==. Replace with .equals(Person.Sex.WOMAN)
| import model.Cat; | ||
| import model.Person; | ||
|
|
||
| public class StreamPractice { |
There was a problem hiding this comment.
Checklist item #5 violation: Use constants instead of magic numbers. Define private static final int MIN_AGE = 35; and use it here
| String[] years = candidate.getPeriodsInUkr().split("-"); | ||
| int yearsInUkr = Integer.parseInt(years[1]) - Integer.parseInt(years[0]); | ||
|
|
||
| return candidate.getAge() >= 35 | ||
| && candidate.isAllowedToVote() | ||
| && "Ukrainian".equals(candidate.getNationality()) | ||
| && yearsInUkr >= 10; |
There was a problem hiding this comment.
Checklist item #5 violation: Use constants instead of magic numbers and strings. Extract 35, "Ukrainian", and 10 as named constants for better code readability and maintainability.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation demonstrates solid understanding of the Stream API, and the Enum comparison issues from before have been successfully fixed. However, there are two constant naming violations in CandidateValidator.java that don't match the checklist requirements [CHECKLIST ITEM #6]: 1. The constant MIN_YEAR should be renamed to MIN_YEARS_IN_UKRAINE 2. The string literal "Ukrainian" should be extracted as REQUIRED_NATIONALITY. These are minor naming adjustments, but the checklist explicitly requires these specific constant names for maintainability and consistency. Once renamed, your code will fully comply with all requirements. Keep up the good work — your logic and stream usage are correct!
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Footnotes
| public class CandidateValidator implements Predicate<Candidate> { | ||
|
|
||
| private static final int MIN_AGE = 35; | ||
| private static final int MIN_YEAR = 10; |
There was a problem hiding this comment.
This constant should be named MIN_YEARS_IN_UKRAINE as specified in checklist item #6, not MIN_YEAR.
|
|
||
| return candidate.getAge() >= MIN_AGE | ||
| && candidate.isAllowedToVote() | ||
| && "Ukrainian".equals(candidate.getNationality()) |
There was a problem hiding this comment.
The string "Ukrainian" should be extracted as a constant named REQUIRED_NATIONALITY as specified in checklist item #6.
| import java.util.stream.IntStream; | ||
| import model.Candidate; |
There was a problem hiding this comment.
Checklist item #6 violation: The constant should be named MIN_YEARS_IN_UKRAINE (not MIN_YEAR). This improves readability and matches the checklist requirement.
No description provided.