Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

generating a unique bank account

Posted on 2004-04-23
5
Medium Priority
?
397 Views
Last Modified: 2010-03-31
Hello, I am wondering if you can help me with my homework assignment.
I am trying to create a program that runs in bank teller machine.  From this teller if existing customer, you can withdraw, deposit and check balances,  If not, you can become a new customer.  When someone becomes a customer, an account number that identifies this particular cliet is generated.  How can I write a method to generate this account number?   The only information I am requesting from the new client is first name, lastname, telephone, and initial desposit.
Thank you.

 
0
Comment
Question by:j_cisek
  • 3
  • 2
5 Comments
 
LVL 92

Expert Comment

by:objects
ID: 10905434
Keep track of last ID generated and just increnment it each time.
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10905440
0
 
LVL 92

Accepted Solution

by:
objects earned 2000 total points
ID: 10905442
public class IDGenerator
{
   int Next = 0;

   public IDGenerator(int lastid)
   {
      Next = lastid;
   }

   public int getNextID()
   {
      return ++Next;
   }
}
0
 
LVL 7

Expert Comment

by:maheshexp
ID: 10905454
simply....just put the numbe generated in the vector, during next number generation, check for it in the vector, or else,generate new number....but careful, u may not be sure that u will always generate unique number or it will take more time, since it can generate the same number if some 1000 numbers or more is in the vector and each time it makes a check and lot of resources will be wasted

 ============
S.M.W
0
 
LVL 92

Expert Comment

by:objects
ID: 10905569
:)
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
This video teaches viewers about errors in exception handling.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question