Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
You are right. We don't need the "else" statment because the previous "returns". Also, the other friend is right too, the right way to compare string (motivations of this in other answer here) is using the .equals(). I adjusted my solution.
Also I don't like "if" clausules without curly braces, although the code will have more lines. More clear is better. I adjusted the spacements too :)
Thank you guys!
It's good solution, but why have you written else statement in the end? Programm will go to command return "green", only if current state wasn't "yellow" or "red".
Yes it's true
mikiPP, I know this solution is old, but still some people try to solve this kata, they fail and after unlocking the solutions they see code like this which obviously is a bad source of knowledge.
Anyway, good to hear you've learned how to correctly compare two strings. :D
Katya, "==" operator tests whether two values are the same object and equals() method checks if values of these objects are the same.
If you want to know more about it, I highly recommend reading this thread: https://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java
You are right, but this code have a long time.I have learned it in the bad way, ty anyway!
Why to avoid?
In this case, using "==" to compare two strings is fine, but generally you should avoid it.
it was still sufficient to solve the kata imo but i changed it anyway
That image looks like Apple UK instead of en-US.
Image of the QWERTY EN_US layout added !
this will be awesome because i can solve this kata but the only problem that i have is the one that i said before
Yeah, I get that. If/when I make a part 2, I'm definitely going to put more thought into other keyboards and key mappings.
i think that is hard to guess which special characters are 2 keystroke and which ones not, because i don't have english keyboard and i don't get any feedback by random tests
When I do the test cases my code works but when I click "ATTEMPT" I have no result because my code takes a long time to execute, I have tried both with "while" and with "for" and the same thing happens to me, it is my fault or there is some error?
Loading more items...