Bookmark Topic Watch Topic
  • New Topic

how 2 do this code

 
vuthlarhi donald
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Report post to moderator
Use your person class to do the following:

Write a class that does the following:
- Creates 10 instances of your person class with all the information filled in (names, email, username, password etc).//I am done with that
- Prompts a user to enter their username and password.// done with that
- if the username/password combination exists for one of your ten users then print out a welcome message as well as all the details of that user.
// how do I determine that
- if the username/password combination fails, allow them to try again.
- if they have filled in the wrong username/password combo for 3 times, display a message informing them of this and quit.
 
Kevin Cahill
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
You could try to determine if the user/pw exists with a case statement. If it finds a match, then print a welcome message. Once you get that working, then add the other 2 requirements. At least that's how I'd begin to approach the problem. Please post a copy or copies of some of the solutions you've tried and we can work through it.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
How are you storing the 10 instances? Hopefully, you're using an array or some collection. maybe there is an easy way to circle around or through your objects, comparing the names on each one to what the user enters...
 
Bill Shirley
Ranch Hand
Posts: 457
 
Campbell Ritchie
Sheriff
Pie
Posts: 49796
69
  • Mark post as helpful
  • send pies
  • Report post to moderator
Welcome to the Ranch, Kevin Cahill.

Are you sure about a switch-case? You can't pass a String to a switch. See this part of the Java Tutorial. But you are correct that Vuthlarhi Donald ought to post some code, even if it doesn't work.
 
Kevin Cahill
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
Thanks Campbell for straightening me out. I looked over the tutorial you suggested. Sorry for the bad advice, I guess I would have found that detail out rather quickly had I tried to use the case statement with a string. I'm a noob to all of this and thought I could learn some things by trying to answer questions....and I did!! I'll try to be more careful in the future, so as not to confuse other's "like me"....
 
fred rosenberger
lowercase baba
Bartender
Posts: 12186
34
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Report post to moderator
follow-ups here
 
    Bookmark Topic Watch Topic
  • New Topic