Skip to content
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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

aunkerrr
Copy link

@aunkerrr aunkerrr commented Jan 3, 2025

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a 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! ✨

Comment on lines 29 to 30
.orElseThrow(() ->
new RuntimeException("Can't get min value from list:" + numbers));

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.

Comment on lines 46 to 47
.orElseThrow(()
-> new NoSuchElementException("Can't get min value from list: " + numbers));

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)

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

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

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

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

Choose a reason for hiding this comment

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

for all places

Suggested change
.collect(Collectors.toList());
.toList();

@aunkerrr aunkerrr requested a review from Elena-Bruyako January 4, 2025 14:35
Copy link
Contributor

@liliia-ponomarenko liliia-ponomarenko left a 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) {
Copy link
Contributor

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

Suggested change
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)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.min(Integer::compare)
.min()

It’s default behavior

Comment on lines +59 to +60
.filter(person -> person.getSex()
.equals(Person.Sex.MAN)
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
.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();
Copy link
Contributor

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

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.

4 participants