Another 7 k monthly salary interview question of softlink power-banking business Scheduling System

Source: Internet
Author: User
Tags lenovo
In the later stage, I added that I am most criticized by netizens for giving students interview questions and saying that they are thieves and scammers. Here, I will explain my interview questions to students as follows:
(1) The student came to the teacher with the interview questions. The student had no way to think about and try it in advance, and he was eager to seek help from the teacher. Out of curiosity about the subject and technology, and out of feelings for the students, the teacher worked tirelessly to help with the problem. Knowing that a child cannot do it on his own doesn't help the child, so he has to exercise the child to do it on his own. Now, it is estimated that many fathers cannot do it on their own. What's more, the students are our customers. We don't want to help them. It seems so cool and heartless.
(2) Some people say that they should let the students do their jobs by themselves. If they cannot do anything, they should not go to the Recruitment Unit to pretend to be good guys. Helping students do their questions is to encourage students to cheat and do evil! From this point on, it is indeed a bit difficult to do things, but it is too heavy to describe things with deception and evil. After all, the employer is not a fool. Can an employer hire a migrant worker to submit the result? The employer had some basic technical assessments and exchanges with the students before doing the exercises. They certainly thought it was almost the same, so that the students could take the questions back home. After the students did the exercises, I also want to explain the code ideas to them. As long as the students can clearly explain the code ideas, the employer may not really care whether the students did it by themselves or if they had some help, because the recruitment positions of many organizations are not right for people, as long as they can handle the tasks they have arranged at work, whether they are handled by themselves or by foreign aid, what the company wants is the result of the incident. Many of my elders have been assigned "Deputy General Manager" in some big companies. Is this elder brother really capable of "Deputy General Manager? No matter whether they have them or not, they can fulfill what the "Deputy General Manager" wants to do based on their own relationships. This is the company's purpose. In the same way, no matter how students do it, as long as the students do it, it means that they or their friends can solve the tasks assigned to him by the company in the future, no matter how he solves it? This may be what the company wants. If so, we have met the company's needs. How can we say that we are cheating and doing evil!
(3) My old idea is: to share the knowledge of the technical problems that I have spent time researching and solving, in order to achieve greater personal and social values. If a person spends a lot of time and energy figuring out the knowledge only in his own stomach and does not have the opportunity to apply it, then this knowledge has no value, only when a knowledge is used by many people and used repeatedly can the value of this knowledge be maximized. Therefore, I have published all these questions and solutions. To attract more people to learn, I certainly want to tell you that this is an interview question and an interview question that determines the success or failure of my work, this is also an incentive to improve everyone's enthusiasm for learning this topic. I didn't expect it to be sent to the cross of moral judgment. Correction:

The previous traffic light management system was originally a face-to-face question of softlink power. Due to a long time, it was forgotten and was mistakenly written as Lenovo Litai. I have a similar interview question [mobile tariff Statistics System] from Lenovo Litai. I will explain it to you in the next blog.

Background:

See the Introduction of traffic light management system. Another student also went to the outsourcing company for an interview and asked him to do the traffic light management system within three days, when I told another student that one of them had come to me first, I could only meet one of them. Otherwise, they would have the same answer, in the end, they both have negative effects. In addition, this classmate said, "Miss Zhang, you just need XXX, don't worry about me." I'm so glad to hear such a derogatory speech, because I do not like to deal with selfish and stingy people. I am certainly happy to meet this type of derogatory student today. After I completed "traffic light Management System", I immediately sent an email to these two students and specially called to inform them of the later students, let him change the code and go to the software outsourcing company to avoid similarities. As a result, the employee called the previous employee and asked him to give the answer to the company first. Then he went over a day later. As expected, the previous employee went to work smoothly. When the employee went to the company to give the answer the next day, the employer said, "The people in the transportation system project team are full, we also have another bank project. The bank project team also needs to recruit people. If you want to, you can go back to a banking system question. If you want to do so, you will enter our bank project team."

To be honest, this software company's recruitment method is really good. I really appreciate this recruitment method. They no longer use the interview questions they get online, instead, we directly use the business in the project to select people. I think this company should also do this out of helplessness. This is to prevent the recruitment of the "Mr. Nan Guo", which is not to take advantage of the work of the interviewer, their company is very large and will not be stingy with such a small amount of work money. This software company is outsourced, and programmers are very mobile. Therefore, it is often necessary to recruit a large number of developers. However, they have recruited too many Mr. Nan Guo before, which makes them complain! They recruited a lot of people who felt they were doing well in the interview, but the performance of their job was totally different from that of the interview. Later, they investigated the cause and found that, now, all the interviewees have taken back the online interview questions, so now it is difficult to find out the real talents through the interview questions. Many of our students have worked in this company. In the past, some of them came back to tell me that they didn't even have a interview question when they went to this company, the company said, "although it makes no sense to do the interview questions now, you should take a good look at these questions to strengthen and review the basic knowledge ", this company gave our students a set of interview questions. When our students came back, they found that this set of questions was similar to my job interview book, and there was almost no difference!

The bank project that the second student obtained is as follows:

Banking Business Scheduling System

 

Download original requirement document
Lecture PPT download lecture source code download
Download lecture videos

 

Simulate and implement the logic of the banking business scheduling system. The specific requirements are as follows:

  • There are 6 business windows in the bank. Window 1-4 is a normal window, window 5 is a quick window, and window 6 is a VIP window.
  • There are three types of customers: VIP customers, ordinary customers, and fast customers (customers who handle services such as water, electricity, and telephone fees ).
  • Users of various types are randomly generated asynchronously. The probability proportions of users of various types are as follows:

VIP customers: common customers: Fast customers = 1: 6: 3.

  • The maximum and minimum time required for the customer to process the business is set. In this range, the time required for each VIP customer and ordinary customer to process the business is set to the minimum time required for the quick customer to process the business (tip: the business process can be simulated by thread sleep ).
  • Each type of customer handles the business in sequence in its corresponding window.
  • When the VIP (6) window and quick business (5) window do not have customers waiting for business processing, these two windows can process the business of ordinary customers, once a corresponding customer is waiting for processing the business, the corresponding customer's business is prioritized.
  • You can set the time interval of randomly generated customers and the maximum and minimum values of business processing time.
  • GUI is not required. You only need to implement the system logic. You can use the LOG method to display the program running results.

Solutions

 

  • Object-Oriented Analysis and Design:

(1) There are three types of customers: VIP customers, common customers, and fast customers. Various types of customers are randomly generated asynchronously, and each type of customers process their businesses in sequence in their corresponding window.
1. first of all, people who often handle business at the bank are more conducive to understanding the system. For example, I often accompany my wife to run the bank, and I am familiar with the banking business, I know that every customer is represented by a number generator of a bank. Therefore, I want to have a number manager object, so that this object will generate a number at random.
2. Because there are three types of customers and each type of customer's number orchestration is completely independent, I think the system will generate three number manager objects, each of which manages the queuing numbers of a class of users. The three phone number manager objects are managed by a single phone number machine. This phone number machine can only have one phone number in the entire system. Therefore, it must be designed as a singleton.
(2) Each type of customer handles the business in sequence in the corresponding window. To be precise, the number of the window should be called in sequence.
1. How do I know the number of each window? It must be the corresponding number manager, that is, the number manager in the service window gets the number to be served each time.
2. if I have not experienced this kind of banking business for many times, and have accumulated a lot of object-oriented application development experience, I do not know if I can easily implement this design, whether or not we can discover the hidden object information is a feeling of accumulation.

(3) class diagram:

 

  • Class encoding implementation

(1) numbermanager class
1. define a set of member variables used to store the previous customer number and a queue used to store all customer numbers waiting for service.
2. Define a method to generate a new number and a method to obtain the number to be served immediately. These two methods are operated on the same data by different threads, So synchronization is required.
The source code is as follows:

 package cn.itcast.bankqueue;import java.util.ArrayList;import java.util.List;public class NumberManager {private int lastNumber = 0;private List queueNumbers = new ArrayList();public synchronized Integer generateNewNumber(){queueNumbers.add(++lastNumber);return lastNumber;}public synchronized Integer fetchNumber(){if(queueNumbers.size()>0){return (Integer)queueNumbers.remove(0);}else{return null;}}}

(2) numbermachine class
1. Define three member variables pointing to three numbermanager objects, indicating the number manager of normal, fast, and VIP customers respectively, and define three corresponding methods to return these three numbermanager objects.
2. design the numbermachine class as a singleton.
The source code is as follows:

package cn.itcast.bankqueue;public class NumberMachine {private NumberMachine(){}private static NumberMachine instance = new NumberMachine();public static NumberMachine getInstance(){return instance;}private NumberManager commonManager = new NumberManager();private NumberManager expressManager = new NumberManager();private NumberManager vipManager = new NumberManager();public NumberManager getCommonManager() {return commonManager;}public NumberManager getExpressManager() {return expressManager;}public NumberManager getVipManager() {return vipManager;}}  

(3) mertype enumeration class
1. There are three types of customers in the system. Therefore, an enumeration class is defined. Three members are defined to represent three types of customers.
2. Override the tostring method and return the Chinese name of the type. This is reconstructed in later encoding.
The source code is as follows:

Package CN. itcast. bankqueue; Public Enum customertype {common, express, VIP; Public String tostring () {string name = NULL; Switch (this) {Case common: Name = "normal"; break; case Express: name = "quick"; break; Case VIP: Name = Name (); break;} return name ;}}

(4) servicewindow class
1. Define a start method, start a thread internally, and call three different methods cyclically according to the service window type.
2. Define three methods to serve three customers respectively. In order to observe the running effect, details should be printed out in detail.
The source code is as follows:

Package CN. itcast. bankqueue; import Java. util. random; import Java. util. concurrent. executors; import Java. util. logging. logger;/*** the VIP window and quick window are not subclass, because normal windows in the actual business can be set as VIP windows and quick windows at any time. **/Public class servicewindow {Private Static logger = logger. getlogger ("CN. itcast. bankqueue "); Private customertype type = customertype. common; private int number = 1; Public customertype GetType () {return type;} public void settype (customertype type) {This. type = type;} public void setnumber (INT number) {This. number = number;} public void start(cmd.exe cute (New Runnable () {public void run () {// The following method is inefficient. It is best to put while under case while (true) {Switch (type) {Case common: commonservice (); break; Case Express: expressservice (); break; Case VIP: vipservice (); break ;}});} private void commonservice () {string windowname = "no." + number + "+ Type +" window "; system. out. println (windowname + "start to get the common task! "); Integer servicenumber = numbermachine. getinstance (). getcommonmanager (). fetchnumber (); If (servicenumber! = NULL) {system. out. println (windowname + "Start with" + servicenumber + "normal customer service"); int maxrandom = constants. max_service_time-constants. min_service_time; int servicetime = new random (). nextint (maxrandom) + 1 + constants. min_service_time; try {thread. sleep (servicetime);} catch (interruptedexception e) {e. printstacktrace ();} system. out. println (windowname + "completed as normal customer service No." + servicenumber + ", total time consumption" + servicetime /1000 + "seconds");} else {system. out. println (windowname + "no common task retrieved, idle for one second"); try {thread. sleep (1000);} catch (interruptedexception e) {e. printstacktrace () ;}} private void expressservice () {INTEGER servicenumber = numbermachine. getinstance (). getexpressmanager (). fetchnumber (); string windowname = "no." + number + "no." + Type + "window"; system. out. println (windowname + "to get the quick task! "); If (servicenumber! = NULL) {system. out. println (windowname + "Start with" + servicenumber + "Quick customer service"); int servicetime = constants. min_service_time; try {thread. sleep (servicetime);} catch (interruptedexception e) {e. printstacktrace ();} system. out. println (windowname + "completed as" + servicenumber + ", fast customer service, total time consumed" + servicetime/1000 + "seconds");} else {system. out. println (windowname + "no quick task found! "); Commonservice () ;}} private void vipservice () {INTEGER servicenumber = numbermachine. getinstance (). getvipmanager (). fetchnumber (); string windowname = "no." + number + "no." + Type + "window"; system. out. println (windowname + "start to get the VIP task! "); If (servicenumber! = NULL) {system. out. println (windowname + "starting from" + servicenumber + "VIP Customer Service"); int maxrandom = constants. max_service_time-constants. min_service_time; int servicetime = new random (). nextint (maxrandom) + 1 + constants. min_service_time; try {thread. sleep (servicetime);} catch (interruptedexception e) {e. printstacktrace ();} system. out. println (windowname + "completed as VIP Customer Service No." + servicenumber + ", total time consumption" + servicetime /1000 + "seconds");} else {system. Out. println (windowname + "didn't get the VIP task! "); Commonservice ();}}}

(5) mainclass class
1. Use the for loop to create four normal windows, and then create one quick window and one VIP window.
2. Create another three timers to regularly create new common customer numbers, new fast customer numbers, and new VIP Customer numbers.
The source code is as follows:

Package CN. itcast. bankqueue; import Java. util. concurrent. executors; import Java. util. concurrent. timeunit; import Java. util. logging. logger; public class mainclass {Private Static logger = logger. getlogger ("CN. itcast. bankqueue "); public static void main (string [] ARGs) {// generates four common windows for (INT I = 1; I <5; I ++) {servicewindow window = new servicewindow (); window. setnumber (I); window. start ();} // generate a quick window servicewind Ow expresswindow = new servicewindow (); expresswindow. settype (customertype. express); expresswindow. start (); // generate one VIP window servicewindow vipwindow = new servicewindow (); vipwindow. settype (customertype. VIP); vipwindow. start (); // executors for common customers. newscheduledthreadpool (1 ). scheduleatfixedrate (New runnable () {public void run () {INTEGER servicenumber = numbermachine. getinstance (). getcommonmanager (). generatenewnumbe R ();/*** using the logger method, you cannot see the intuitive running effect, because logger. the log method does not directly print the content out, * It is handed to an internal thread for processing. Therefore, the printed results seem messy in chronological order. * /// Logger.info ("no." + servicenumber + ") regular customers are waiting for service! "); System. Out. println (" no. "+ servicenumber +" normal customers are waiting for service! ") ;}}, 0, constants. common_customer_interval_time, timeunit. seconds); // The Quick client obtains the number executors. newscheduledthreadpool (1 ). scheduleatfixedrate (New runnable () {public void run () {INTEGER servicenumber = numbermachine. getinstance (). getexpressmanager (). generatenewnumber (); system. out. println ("no." + servicenumber + ", the customer is waiting for service! ") ;}}, 0, constants. common_customer_interval_time * 2, timeunit. seconds); // executors for VIP customers. newscheduledthreadpool (1 ). scheduleatfixedrate (New runnable () {public void run () {INTEGER servicenumber = numbermachine. getinstance (). getvipmanager (). generatenewnumber (); system. out. println ("no." + servicenumber + "VIP customers are waiting for service! ") ;}}, 0, constants. common_customer_interval_time * 6, timeunit. Seconds );}}

(6) constants class
1. Define three constants: max_service_time, min_service_time, and common_customer_interval_time.
The source code is as follows:

Package CN. itcast. bankqueue; public class constants {public static int max_service_time = 10000; // 10 seconds! Public static int min_service_time = 1000; // 1 second! /* Each common window serves a customer with an average time of 5 seconds. There are 4 such windows in total, that is to say, all common windows of a bank can be combined * to serve a common customer in an average of 1.25 seconds, and the quick window and VIP window can also serve ordinary customers, * It is reasonable to generate a common customer in one second. */public static int common_customer_interval_time = 1 ;}
• In the previous article, the interview of famous enterprises is based on the soft communication power to give interview questions with a monthly salary of 7 K
Related Article

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.