jQuery in Action, 2nd edition*
The moose likes Beginning Java and the fly likes how 2 do this code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply locked New topic

how 2 do this code

vuthlarhi donald
Ranch Hand

Joined: Jul 31, 2006
Posts: 76
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

Joined: Jan 08, 2008
Posts: 9
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.

Persistence and determination alone are omnipotent.<br />---Calvin Coolidge
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11153

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...

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Bill Shirley
Ranch Hand

Joined: Nov 08, 2007
Posts: 457
[ January 09, 2008: Message edited by: Bill Shirley ]

Bill Shirley - bshirley - frazerbilt.com
if (Posts < 30) you.read( JavaRanchFAQ);
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 37936
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

Joined: Jan 08, 2008
Posts: 9
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

Joined: Oct 02, 2003
Posts: 11153

follow-ups here
I agree. Here's the link: http://aspose.com/file-tools
subject: how 2 do this code
Similar Threads
help looping through objects
JDBC Connections Freezing with Multiple Users Accessing DB
help with this program! I am stuck
help people for the last time
can anyone help me