| Author |
String Validation Issues
|
Mark Captain
Ranch Hand
Joined: Nov 01, 2011
Posts: 30
|
|
Hello, in my program I am trying to validate if a password is correct. However I am coming up with the problem of the code saying the password is incorrect even when it is correct. it looks as it is not comparing the newly inputted password but it is using the one declared in the driver. Any ideas?
The two strings i am trying to compare are the users input password, and the saved password. The are declared in the main driver like so
The method is called in the driver
The readPassword method
and the validation method
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1778
|
|
|
Please print the two passwords you compare in the validatePassword() method before the line #5.
|
 |
Claudiu Chelemen
Ranch Hand
Joined: Mar 25, 2011
Posts: 65
|
|
Hi Mark,
First off, I see that even if your readPassword method is returning the typed password, you are not using it in the driver, here:
I guess it would be better if you had:
Secondly, when calling the validatePassword method, you may have accidentally sent the first two parameters, password and PASSWORD in the incorrect order.
Cheers,
Claudiu
|
 |
Claudiu Chelemen
Ranch Hand
Joined: Mar 25, 2011
Posts: 65
|
|
John Jai wrote:Please print the two passwords you compare in the readPassword() method before the line #5.
I think you meant the validatePassword() method, right ?
Claudiu
|
 |
John Jai
Bartender
Joined: May 31, 2011
Posts: 1778
|
|
|
Yes... thanks for correcting it..
|
 |
Mark Captain
Ranch Hand
Joined: Nov 01, 2011
Posts: 30
|
|
Claudiu Chelemen wrote:Hi Mark,
First off, I see that even if your readPassword method is returning the typed password, you are not using it in the driver, here:
I guess it would be better if you had:
Secondly, when calling the validatePassword method, you may have accidentally sent the first two parameters, password and PASSWORD in the incorrect order.
Cheers,
Claudiu
Thank you, this solved my problem!
|
 |
 |
|
|
subject: String Validation Issues
|
|
|