[Dark horse programmer Java training and Android training] Bank Scheduling System

Source: Internet
Author: User

Banking Business Scheduling System

At ordinary times, we have probably been to the bank to get or save the money, and a slightly larger bank will have a management system.
The functions required in word are basically the same as in reality. Learn the video to summarize what the system should pay attention.

1. Objects and information of the class to be extracted

Based on actual experience, we extract three objects: customer, ticket receiving machine, and console.

2. How are customers produced in the program?

We know that there are air conditioners in the Bank, especially in the summer, there may be many people in it, most of whom handle the business. We call it a customer,
We are looking for the target, but some people are playing the cold. They certainly cannot be regarded as customers. How can we distinguish them?
We use the number receiving machine object. If we generate a ticket in the number receiving machine, it is equivalent to generating a customer. In this case, we can let this customer
In the "team.

3. "nickname"

What is the call number? Is it because the customer ran to question mark? Said, is it my turn? I always ask, if there are more than N Customers, more than N Customers will also ask at the same time,
The window burst! Therefore, you cannot ask the customer to run the question mark. Instead, you can call the phone number in the window. When the customer hears the phone number in the window
Go to the corresponding window to handle the business.

4. the structure in the system is clear.
Numbermanager has all the methods related to number
NumberMachine has Vip, fast, and common Manager
ServiceWindow has a business processing method

5. NumberManger

Public class NumberManager {
Private int lastNumber = 0;
Private list queuenumbers = new arraylist ();
// Arraylist is not used here for interface-oriented programming. It can be used in the future as a new feature list for convenience.

Public synchronized integer generatenewnumber (){
Queuenumbers. Add (++ lastnumber); // Add this number
Return lastnumber;
}

Public synchronized integer fetchnumber (){
If (queuenumbers. Size ()> 0 ){
Return (integer) queuenumbers. Remove (0); // The remove () method returns an element in a set.
} Else {
Return NULL;
}
}

6. numbermachine

Private numbermachine () {}// machines that manage three numbers
Private Static numbermachine instance = new numbermachine (); |
Public static NumberMachine getInstance () {| ----> singleton. Make sure that there is only one instance in the singleton object. There is a singleton in the enumeration we learned last time.
Return instance; | use static Modification
}
// Three member variables
Private NumberManager commonManager = new NumberManager (); // common customer
Private NumberManager expressManager = new NumberManager (); // Quick customer
Private NumberManager vipManager = new NumberManager (); // vip Customer
Public NumberManager getCommonManager (){
Return commonManager;
}
Public NumberManager getExpressManager (){
Return expressmanager;
}
Public numbermanager getvipmanager (){
Return vipmanager;
}

7. servicewindow

The servicewindow class is called, so does its call function call other people's or own?
How can we implement it if it is his own?
Write a start () in the class to create a thread pool to run the commonservice (), expressservice (), vipservice () methods.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.