Skip to content

did#1408

Open
Polya555 wants to merge 3 commits into
mate-academy:mainfrom
Polya555:main
Open

did#1408
Polya555 wants to merge 3 commits into
mate-academy:mainfrom
Polya555:main

Conversation

@Polya555

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

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

@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

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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example

public List<Person> selectMenByAge(List<Person> peopleList, int fromAge, int toAge) {
return Collections.emptyList();
return peopleList.stream()
.filter(p -> p.getSex() == Person.Sex.MAN

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #5 violation: Use constants instead of magic numbers. Define private static final int MIN_AGE = 35; and use it here

Comment on lines +10 to +16
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;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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 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

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

  1. Rate AI review example

public class CandidateValidator implements Predicate<Candidate> {

private static final int MIN_AGE = 35;
private static final int MIN_YEAR = 10;

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 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())

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 string "Ukrainian" should be extracted as a constant named REQUIRED_NATIONALITY as specified in checklist item #6.

Comment on lines +8 to 9
import java.util.stream.IntStream;
import model.Candidate;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #6 violation: The constant should be named MIN_YEARS_IN_UKRAINE (not MIN_YEAR). This improves readability and matches the checklist requirement.

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