According to the requirement analysis and the actual situation of waiting in the bank and the object oriented design, it is necessary to clearly have 3 objects, namely the window, the customer and the number-taking machine. Again according to different
function to implement it.
In writing the management number of the time to note that the number and call is synchronized, so pay attention to the Synchronized keyword. The machine is only one in the system, so make him
A single example.
The teacher in the video and cleverly used the enumeration class, the customer's type is represented by enumerations, and most importantly, the switch statement can receive parameters of the enumeration type, and more than if
Else efficiency is much higher.
Next is to implement the window class method, according to different customer needs, get different types of numbers to calculate the relevant time difference, in order to make the code can be reused, you can put the Quick window
With the VIP window are made into ordinary customers subclass, cover the method of the parent class, replace some of these methods, is the code more concise, more technical content.