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

Practice Completed #1216

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

Practice Completed #1216

wants to merge 3 commits into from

Conversation

MishaHMK
Copy link

@MishaHMK MishaHMK commented Jan 9, 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 mostly aligns with the task specifications. There are a few minor issues to address, such as correcting the exception messages in the findMinEvenNumber and getOddNumsAverage methods, and optimizing the workablePredicate for better readability. These are small tweaks that will enhance your code quality. Keep up the excellent work and continue refining your skills! 😊

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

@@ -14,7 +19,21 @@ public class StreamPractice {
* "Can't get min value from list: < Here is our input 'numbers' >"
*/
public int findMinEvenNumber(List<String> numbers) {
return 0;
final String errorMessage = "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 should be formatted as "Can't get min value from list: " + numbers, according to the checklist requirement.

Comment on lines 49 to 50
.orElseThrow(() ->
new NoSuchElementException("No even number found in list"));

Choose a reason for hiding this comment

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

The exception message should state "No odd number found in list" instead of "No even number found in list" to accurately reflect the operation being performed.

Comment on lines +83 to +87
Predicate<Person> workablePredicate = p ->
(p.getSex() == Person.Sex.WOMAN
&& p.getAge() <= femaleToAge)
|| (p.getSex() == Person.Sex.MAN
&& p.getAge() <= maleToAge);

Choose a reason for hiding this comment

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

Consider including the lower bound age check (fromAge) within the workablePredicate to avoid redundancy and improve readability.

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! Let’s improve your solution ;)

src/main/java/practice/CandidateValidator.java Outdated Show resolved Hide resolved
Comment on lines 28 to 30
return Arrays.stream(numbers.stream()
.collect(Collectors.joining(","))
.split(","))
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
return Arrays.stream(numbers.stream()
.collect(Collectors.joining(","))
.split(","))
return Arrays.stream(numbers.split(","))

Redundant converting

Copy link
Author

Choose a reason for hiding this comment

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

my input example -> {"5,30,100", "0,22,7", ...}

so i must connect this strings in single one before splitting

am i wrong?

src/main/java/practice/StreamPractice.java Outdated Show resolved Hide resolved
Comment on lines +24 to +26
if (numbers.isEmpty()) {
throw new RuntimeException(errorMessage);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant check (stream returns the same result )

src/main/java/practice/StreamPractice.java Outdated Show resolved Hide resolved
src/main/java/practice/StreamPractice.java Outdated Show resolved Hide resolved
src/main/java/practice/StreamPractice.java Outdated Show resolved Hide resolved
src/main/java/practice/StreamPractice.java Outdated Show resolved Hide resolved
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