Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Help please  RSS feed

 
Mike Corbett
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im tryingto write a program that accepts a user's password from the key board. The password needs to be more than 6 characters and less than 10 with at least 1 number and 1 letter or it won't let the user move on. Then once it meets those requirements they have to re-enter the passord, and not let them move on untill the two match. The problem I'm having is I can get the user to type in a passowrd but I don't know how to make them use at least one letter and one number and not let them go on untill they do. Any help would be appreciated.
 
David McCombs
Ranch Hand
Posts: 212
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Think about the process. You have to wait until the user hits enter to be able to validate it.

So once you have the String from the user some simple method calls to String will determine whether it is valid. Does this sound like it should be its own method that returns the result of its validity?

If it is not valid(returns false), then what mechanism exists that will allow you to repeat the process?

Hopefully, this can help you on your way.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!