aspose file tools*
The moose likes Java in General and the fly likes problem with  method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "problem with  method "validRoomNumber" Watch "problem with  method "validRoomNumber" New topic
Author

problem with method "validRoomNumber

Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
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
Ravikanth kolli
Ranch Hand

Joined: Feb 10, 2008
Posts: 179

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...


-kolli
Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
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

Joined: Mar 20, 2008
Posts: 36
hello anyone ..i need help :roll:
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

How are you testing this?


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
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

Joined: Aug 31, 2004
Posts: 11343

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

Joined: Mar 20, 2008
Posts: 36
oh my bad i posted the tokenizer i was not using it anyway, now i finally got my code working
Pepo moussa
Ranch Hand

Joined: Mar 20, 2008
Posts: 36
the problem was at my testing i was testing it the wrong way :S
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: problem with method "validRoomNumber