Skip to content

homeSo;#1395

Open
yarroslaw3842o84023984902 wants to merge 2 commits into
mate-academy:mainfrom
yarroslaw3842o84023984902:homSol
Open

homeSo;#1395
yarroslaw3842o84023984902 wants to merge 2 commits into
mate-academy:mainfrom
yarroslaw3842o84023984902:homSol

Conversation

@yarroslaw3842o84023984902

Copy link
Copy Markdown

No description provided.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

This is a solid attempt, and you've correctly used the Stream API for most of the tasks. However, some changes are needed in the CandidateValidator class as its current implementation doesn't meet the requirements, which causes the candidate selection task to fail.

Specifically, there are two issues that need to be addressed:

  1. Incorrect Age Validation: The requirement is for a candidate to be "at least 35 years old" (inclusive). Your current logic incorrectly rejects candidates who are exactly 35. Please adjust the condition to correctly include them.
  2. Magic String Usage: The hardcoded string "Ukrainian" violates the project's coding standards [CHECKLIST ITEM #6]. This value should be declared as a private static final String constant at the top of the class.

Once you've fixed these two points, your solution will be ready. Keep up the great work!


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


@Override
public boolean test(Candidate c) {
if (c.getAge() <= MIN_AGE) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The requirement is for a candidate to be "at least 35 years old", which is inclusive. This condition c.getAge() <= 35 incorrectly rejects candidates who are exactly 35. The check should ensure that ages 35 and older are considered valid.

if (!c.isAllowedToVote()) {
return false;
}
if (!"Ukrainian".equals(c.getNationality())) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates checklist item #6: 'Use constants'. The string "Ukrainian" is a magic value. It should be defined as a private static final String constant at the top of the class to improve readability and make future changes easier.

public List<String> validateCandidates(List<Candidate> candidates) {
return Collections.emptyList();
return candidates.stream()
.filter(new CandidateValidator())

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This filter uses CandidateValidator, which doesn't correctly implement the requirements.

  1. The age validation is for "older than 35" (> 35), but the description file requires "at least 35 years old" (>= 35). This will incorrectly exclude candidates who are exactly 35.
  2. The validator uses the magic string "Ukrainian". According to checklist item Stream practice by ok #6, this should be a constant.

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Excellent work on this revision! You've successfully addressed all the previous feedback, and your solution now correctly implements all the required functionality. Your use of the Stream API is clean and efficient. I've left one minor inline comment in StreamPractice.java with a suggestion to improve readability, but it's not a required change. Please be sure to fix the Checkstyle violations reported by the automated checks so your pull request can be merged. Since all functional requirements are met, I am approving your submission. Great job!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example

Comment on lines +84 to +89
.filter(el -> el.getSex().equals(Person.Sex.MAN)
&& el.getAge() >= fromAge
&& el.getAge() <= maleToAge
|| el.getSex().equals(Person.Sex.WOMAN)
&& el.getAge() >= fromAge
&& el.getAge() <= femaleToAge)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic is correct, but the combined condition is a bit long and can be hard to read. You can make it clearer by factoring out the common age check (el.getAge() >= fromAge). For example: .filter(el -> el.getAge() >= fromAge && ((isMan && age <= maleToAge) || (isWoman && age <= femaleToAge))).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants