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

how 2 do this code

 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
http://faq.javaranch.com/java/ShowSomeEffort
http://faq.javaranch.com/java/CarefullyChooseOneForum
http://faq.javaranch.com/java/UseAMeaningfulSubjectLine
http://faq.javaranch.com/java/DoYourOwnHomework
http://faq.javaranch.com/java/UseRealWords
[ January 09, 2008: Message edited by: Bill Shirley ]
 
Marshal
Posts: 79177
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
follow-ups here
 
    Bookmark Topic Watch Topic
  • New Topic