-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jv-stream-github-practice-01 #1212
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job on implementing the task requirements! 🎉 Your code is well-structured and meets the core functionality needed for the task. There are a few minor issues, such as the exception message formatting and a condition adjustment for inclusivity, but they don't impact the overall functionality. Keep up the great work and consider these suggestions for future improvements! 😊
✨ Please rate this review in the Platform's notification center. I will be grateful for your feedback! ✨
.orElseThrow(() -> | ||
new RuntimeException("Can't get min value from list:" + numbers)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message in the findMinEvenNumber
method should include a space after the colon, as specified in the checklist: "Can't get min value from list: " + numbers.
.orElseThrow(() | ||
-> new NoSuchElementException("Can't get min value from list: " + numbers)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The exception message here refers to getting the minimum value, but this method is about calculating the average. Consider updating the message to reflect the correct operation, such as: "Can't get average value from list: " + numbers.
return Collections.emptyList(); | ||
return peopleList.stream() | ||
.filter(pw -> pw.getSex() | ||
.equals(Person.Sex.WOMAN) && pw.getAge() > femaleAge) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition pw.getAge() > femaleAge
should be pw.getAge() >= femaleAge
to match the task requirement of inclusivity from femaleAge
years old.
public boolean test(Candidate candidate) { | ||
return candidate.getAge() >= MIN_AGE | ||
&& candidate.isAllowedToVote() | ||
&& "Ukrainian".equalsIgnoreCase(candidate.getNationality()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create constant for "Ukrainian"
} | ||
|
||
private boolean hasLivedInUkraineFor10Years(String periodsInUkr) { | ||
return Arrays.stream(periodsInUkr.split(",")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create constants for comma and delimiter, for 1 and 0 also
public List<Person> selectMenByAge(List<Person> peopleList, int fromAge, int toAge) { | ||
return Collections.emptyList(); | ||
return peopleList.stream() | ||
.filter(p -> p.getSex() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename p
check everywhere
.equals(Person.Sex.MAN) | ||
&& p.getAge() >= fromAge | ||
&& p.getAge() <= toAge) | ||
.collect(Collectors.toList()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for all places
.collect(Collectors.toList()); | |
.toList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! A few recommendations ;)
&& hasLivedInUkraineFor10Years(candidate.getPeriodsInUkr()); | ||
} | ||
|
||
private boolean hasLivedInUkraineFor10Years(String periodsInUkr) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid values in the methods name
private boolean hasLivedInUkraineFor10Years(String periodsInUkr) { | |
private boolean hasLivedInUkraineRequiredPeriod(String periodsInUkr) { |
.flatMap(line -> Arrays.stream(line.split(","))) | ||
.map(Integer::parseInt) | ||
.filter(n -> n % 2 == 0) | ||
.min(Integer::compare) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.min(Integer::compare) | |
.min() |
It’s default behavior
.filter(person -> person.getSex() | ||
.equals(Person.Sex.MAN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.filter(person -> person.getSex() | |
.equals(Person.Sex.MAN) | |
.filter(person -> person.getSex() == (Person.Sex.MAN) |
you can compare enums using ==
public List<String> validateCandidates(List<Candidate> candidates) { | ||
return Collections.emptyList(); | ||
CandidateValidator candidateValidator = new CandidateValidator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better make it a class-level variable
No description provided.