-
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
Practice Completed #1216
base: main
Are you sure you want to change the base?
Practice Completed #1216
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 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; |
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 should be formatted as "Can't get min value from list: " + numbers, according to the checklist requirement.
.orElseThrow(() -> | ||
new NoSuchElementException("No even number found in list")); |
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 should state "No odd number found in list" instead of "No even number found in list" to accurately reflect the operation being performed.
Predicate<Person> workablePredicate = p -> | ||
(p.getSex() == Person.Sex.WOMAN | ||
&& p.getAge() <= femaleToAge) | ||
|| (p.getSex() == Person.Sex.MAN | ||
&& p.getAge() <= maleToAge); |
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.
Consider including the lower bound age check (fromAge) within the workablePredicate
to avoid redundancy and improve readability.
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! Let’s improve your solution ;)
return Arrays.stream(numbers.stream() | ||
.collect(Collectors.joining(",")) | ||
.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.
return Arrays.stream(numbers.stream() | |
.collect(Collectors.joining(",")) | |
.split(",")) | |
return Arrays.stream(numbers.split(",")) |
Redundant converting
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.
my input example -> {"5,30,100", "0,22,7", ...}
so i must connect this strings in single one before splitting
am i wrong?
if (numbers.isEmpty()) { | ||
throw new RuntimeException(errorMessage); | ||
} |
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.
Redundant check (stream returns the same result )
No description provided.