• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

problem with method "validRoomNumber

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i got a problem with this method which suppose to read a string and check a room number if the 1st letter is upper case or a number and the rest of the room is digits it should return true else false
i do not know what is wrong really but i keep getting error saying else without if so anyone can help
 
Ranch Hand
Posts: 179
Mac Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
i think the problem is with the return and not with the if else statements. The final else part returns the value false, but in the if the value is returned if the inner if and the for loop is executed. If they are not executed it is not returning anything. check that out and see if that works..

I could not find any other errors with the paranthesis...
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
that is my final code nothing with no error but it does not work as i wane it to work ? any idea

 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello anyone ..i need help :roll:
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you testing this?
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh well have example if the string "A123" its true or "123" also true the 1st letter has to be capital or a digit and the rest of the string has to digits so string like that "a123" should not work and return false, or "A123a" also wrong and the method should return false.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by I moussa:
oh well have example if the string "A123" its true or "123" also true the 1st letter has to be capital or a digit and the rest of the string has to digits so string like that "a123" should not work and return false, or "A123a" also wrong and the method should return false.


Yes, but what happens when you test using these examples?

For example, how would "A123" be split by this tokenizer? And what would happen if there aren't exactly 3 tokens?
[ March 22, 2008: Message edited by: marc weber ]
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
oh my bad i posted the tokenizer i was not using it anyway, now i finally got my code working
 
Pepo moussa
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the problem was at my testing i was testing it the wrong way :S
 
reply
    Bookmark Topic Watch Topic
  • New Topic