Generate_Class
1| import java.awt.*;
2| import javax.swing.*;
3|
4| public class Generate_Class
5| {
6| final static long serialVersionUID = 5;
7|
8| public Generate_Class()
9| {
10|
11| }
12|
13| public void Gen_Rand(JTextField[] txtField)
14| {
15| int[] iWhite = new int[5];
16|
17| int iWHigh = 55;
18| int iRHigh = 42;
19|
20| int iSingWhite;
21| int iSingRed;
22|
23| Random_Number_Class oRand = new Random_Number_Class();
24|
25| for(int iX = 0; iX < 5; iX++)
26| {
27| boolean dup_sw = true;
28|
29| iSingWhite = oRand.Random(iWHigh);
30|
31| for(int iY = 0; iY < iX; iY++)
32| {
33| if(iWhite[iY] == iSingWhite)
34| {
35| dup_sw = false;
36| break;
37| }
38| }
39|
40| if(dup_sw)
41| {
42| iWhite[iX] = iSingWhite;
43| }
44| else
45| {
46| iX--;
47| }
48|
49| }
50|
51| for(int ix = 0; ix < 5; ix++)
52| {
53| txtField[ix].setText(Integer.toString(iWhite[ix]));
54| txtField[ix].setBackground(Color.white);
55| }
56|
57| iSingRed = oRand.Random(iRHigh);
58| txtField[5].setText(Integer.toString(iSingRed));
59| txtField[5].setBackground(Color.red);
60|
61| }
62|
63| }