综合管理平台数据库数据模拟程序
whyclxw
2021-03-25 218a7f91026d7fab28f2f8a1416e90751717f9e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package com.mode;
 
import java.math.BigDecimal;
import java.util.Random;
 
public class Manage_Util{
    
    public static final int DEV_TYPE_DYNAMICLOAD = 1001;        //Ë®Àä¸ºÔØ
    public static final int DEV_TYPE_MOTOR        = 1002;        //¼ÓÔØµç»ú
    public static final int DEV_TYPE_4MWPOWER    = 1003;        //1ºÅ,2ºÅ´ó¹¦ÂÊÕûÁ÷µçÔ´
    public static final int DEV_TYPE_2MWPOWER    = 1004;        //3ºÅ´ó¹¦ÂÊÕûÁ÷µçÔ´
    public static final int DEV_TYPE_WATER    = 1005;        //3ºÅ´ó¹¦ÂÊÕûÁ÷µçÔ´
    /**
     *     Ëæ»úÉú³É¿ª¹ØÁ¿±äÁ¿
     * @return
     */
    public static int CreateSwitchRanDom() {
        return new BigDecimal(Math.random()).setScale(0, BigDecimal.ROUND_HALF_UP).intValue();
    }
    
    /**
     *     Ëæ»úÉú³É1»òÕß-1
     * @return
     */
    public static int CreateIntRandom() {
        Random rand = new Random();
       if (rand.nextBoolean())
          return 1;
       else
          return -1;
    }
    
    /**
     *     Éú³ÉÕûÊýËæ»úÊý
     * @return
     */
    public static int CreateIntRanDom() {
        return new Random().nextInt();
    }
    
    /**
     *     Éú³ÉÕûÊýËæ»úÊý
     * @return °üº¬min,²»°üº¬max
     */
    public static int CreateIntRanDom(int min,int max) {
        return (min + ((int) (new Random().nextFloat() * (max - min))));
    }
    
    /**
     *     Éú³É0.0-1.0Ö®¼äµÄfloatËæ»úÊý
     * @return  °üº¬0.0²»°üº¬1.0
     */
    public static float CreateFloat0To1() {
        return new Random().nextFloat();
    }
    
    /**
     *     Éú³ÉÓб߽çµÄfloat Ëæ»úÊý
     * @param min
     * @param max
     * @return
     */
    public static float CreateFloatRanDom(float min,float max) {
        return (min + new Random().nextFloat() * (max - min));
    }    
    
    public static void main(String[] args) {
        for(int i=0;i<1000;i++) {
            System.out.println(CreateIntRandom());
        }
    }
}