• 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

String Validation Issues

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please print the two passwords you compare in the validatePassword() method before the line #5.
 
Ranch Hand
Posts: 75
Eclipse IDE Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 75
Eclipse IDE Oracle Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes... thanks for correcting it..
 
Mark Captain
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic