First, demand analysis
1. Display the candidate's photo and name.
2. A lottery can be used in a variety of modes, including one individual draw, two simultaneous draws and three simultaneous draws.
3. A person can obtain one or two, third prize in a different batch of sweepstakes, but cannot obtain multiple prizes in the same batch of sweepstakes.
Ii. overall framework of the system
System requirements are relatively simple, using the Java Swing technology can be well implemented, the overall class framework diagram of the system is as follows
Description: Based on the main three classes will be able to complete the required functions, frame has a panel type and mouseadapter type of members, the panel main users to store specific controls and draw the appropriate information, Mouseadapter is mainly used in response to mouse click action.
Third, the system implementation details
1. Photos rotate display effect-timer
Since it is a lottery system, so there must be a picture of the candidates to roll up the effect, then how to achieve it? With a timer, every 100ms to start a timer, you can let each 100ms display different candidate's photos and names.
2. The same candidate cannot receive multiple prizes in the same batch-loop algorithm
How can I ensure that the same candidate does not receive multiple prizes when making a lottery in multiplayer mode? A loop algorithm is used, and if the number of randomly generated numbers is the same, it is regenerated until the number generated by the same batch is different.
3. How candidates ' photos and names correspond-two linked list implementations
Use two linked lists to ensure that scrolling photos and names correspond, provided that the photo name is composed of the candidate's name + photo format, such as Leesf.jpg. In this way, when the photo is read, the name of the photo is parsed, the name is extracted, and the photos and names are added to the list of photos and lists of names, so that at the time of fetching the photos linked list and the name of the linked lists of the corresponding items.
Iv. List of codes
This system code has been uploaded to GitHub. Address: Https://github.com/leesf/LuckDrawSystem.git welcome you to fork and download the Park friends.
Five, the operation
System interface
Menu bar
Vi. Summary
A very simple lottery system, the reader needs to be able to adapt to their own needs. Thank you for watching the Garden friends ~
"Small system" lottery system-complete with Java Swing