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

Add implementation to TextProcessorJDK.topVowelAndConsonant() for haiku-kata-solutions module #296 #345

Merged
merged 1 commit into from
Sep 25, 2023

Conversation

rsp2210
Copy link
Contributor

@rsp2210 rsp2210 commented Sep 23, 2023

Fix #296

Copy link
Contributor

@rzrobin213 rzrobin213 left a comment

Choose a reason for hiding this comment

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

Few changes!

// Find all of the alphabetic letters from the haiku, convert them to lowercase,
// and count the Character values in a Map.
Map<Character, Long> charCounts = this.getHaikuAsChars()
.stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

IntStream does not have the method .stream() so this code doesn't compile. You already have an IntStream, you just need to convert it into a stream of character objects. I would take a look at the IntStream.mapToObj(IntFunction<? extends U> mapper) function.

https://docs.oracle.com/javase/8/docs/api/java/util/stream/IntStream.html

Copy link
Contributor Author

@rsp2210 rsp2210 Sep 23, 2023

Choose a reason for hiding this comment

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

I worked on the solution as per your suggestions. Thanks for the link, It was helpful in understanding the function better.


// Find the top vowel.
char topVowel = entries.stream()
.filter(this::isVowel)
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for being unclear. I think you need to .getKey() to use the isVowel method. entries is a list of map objects and isVowel only has aa char as input. So, using a lambda with .getKey on the map makes sense to me, just like how you had in the previous one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries. I made the necessary adjustments and updated the code accordingly. Thanks again for catching that.


// Find the top consonant.
char topConsonant = entries.stream()
.filter(!this::isvowel)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment as above; I believe you had it right in the last time. I just wanted to get you to change the previous one. Sorry for the confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No need to apologize; I appreciate your input and feedback!

Copy link
Contributor

@rzrobin213 rzrobin213 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Nice work!

@rsp2210 rsp2210 closed this Sep 23, 2023
@rsp2210 rsp2210 reopened this Sep 23, 2023
@rsp2210
Copy link
Contributor Author

rsp2210 commented Sep 23, 2023

Thank you! I closed it by mistake, I reopened it, sorry.

@prathasirisha
Copy link
Contributor

Thank you for your contribution @rsp2210 and thank you, @rzrobin213 for the code review! Good work.

@prathasirisha prathasirisha merged commit 484419f into eclipse-collections:master Sep 25, 2023
4 checks passed
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.

Add implementation to TextProcessorJDK.topVowelAndConsonant() for haiku-kata-solutions module
3 participants