• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Boolean value does not change

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I know it should be very easy, but boolean variable is not updating, could please someone point me the error I can't see? Thank you
 
Saloon Keeper
Posts: 2613
329
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you expecting, and what are you seeing for a given input?

If an isogram is a phrase without a repeating character, then it seems like your logic is reversed.  The default is that it is not an isogram, but when you detect a repeated character, the result is being updated to indicate that it is an isogram.
 
Ron McLeod
Saloon Keeper
Posts: 2613
329
Android Eclipse IDE Angular Framework MySQL Database TypeScript Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.. and Welcome to CodeRanch!  
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:.. and Welcome to CodeRanch!  


Thank you
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:What are you expecting, and what are you seeing for a given input?

If an isogram is a phrase without a repeating character, then it seems like your logic is reversed.  The default is that it is not an isogram, but when you detect a repeated character, the result is being updated to indicate that it is an isogram.



Yes, sorry I reversed the logic. I changed the values accordingly  now, but still I can't pass this test:

Even if on a online compiler works just fine. Am I just flipping out after a whole afternoon coding? :\
 
Bartender
Posts: 5897
57
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you handling upper-case vs lower-case? Do you know which assert it is failing on?
 
Bartender
Posts: 2290
95
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think a single loop can easily figure out an Isogram like this:
As Carey suggested, a better method signature can be:
Can you work out the changes required for ignoring case ?
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've added and one case is passed. Ave. In the another one: .
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:I think a single loop can easily figure out an Isogram like this:
As Carey suggested, a better method signature can be:
Can you work out the changes required for ignoring case ?


I tried your code, it didn't pass the test. One test passed, the other one: expected:<false> but was:<true>.
Thank you guys
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And I've also added: for the last line
The error still there though.
 
Marshal
Posts: 64618
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sabrina Cux wrote:. . . for the last line . . .

You know == doesn't work on Strings.
 
salvin francis
Bartender
Posts: 2290
95
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think my code would only fail for "moOse" since my code does not ignore case. It should also work for blank string so no blank check is required.
Can you work out a case-insensitive solution ?
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Campbell Ritchie wrote:

Sabrina Cux wrote:. . . for the last line . . .

You know == doesn't work on Strings.



Aaahh my bad! Changed, but the issue was not that one. And thanks for the link as refresh!
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:I think my code would only fail for "moOse" since my code does not ignore case. It should also work for blank string so no blank check is required.
Can you work out a case-insensitive solution ?


Yep!!! Your code does work! Thanks for your solution, my way keeps its mystery.
 
salvin francis
Bartender
Posts: 2290
95
Google Web Toolkit Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Sabrina Cux wrote:... Thanks for your solution, my way keeps its mystery.


Can you share how you have solved it for case sensitivity ?
 
Sabrina Cux
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For solving Case Sensitivity:
Just added str.toLowerCase() before doing any operation on the string. That should be enough.
 
Saloon Keeper
Posts: 3289
145
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

salvin francis wrote:
       // -- Wish I knew a shorter way to convert String to List of characters


Using 'var' and a static import you can shorten it to:
 
Piet Souris
Saloon Keeper
Posts: 3289
145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The static import I am referring to is:

And if you have to use java 8-, then you realize what a type-saver 'var' is!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!