summaryrefslogtreecommitdiff
path: root/src/MyResource.java
blob: 0ec1aac3052037cf89e61731ff596ab0bdc90606 (plain)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/* 
    Nie mieszac  z java.awt.*  (!!!)
*/
package src;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.util.*; 
import java.lang.*;


class MyResource {
    final int MAX_WORDS=67656;

    public void MyResource()
    {
    }
    private static final String absName = "/slownik.txt";
    // TODO - to jest mniej eleganckie;
    static ArrayList<String> directory3 = new ArrayList<String>();
    static ArrayList<String> directory4 = new ArrayList<String>();
    static ArrayList<String> directory5 = new ArrayList<String>();
    static ArrayList<String> directory6 = new ArrayList<String>();
    static ArrayList<String> directory7 = new ArrayList<String>();
    static ArrayList<String> directory8 = new ArrayList<String>();
    static ArrayList<String> directory9 = new ArrayList<String>();
    static ArrayList<String> directory10 = new ArrayList<String>();
    static ArrayList<String> directory11 = new ArrayList<String>();
    static ArrayList<String> directory12 = new ArrayList<String>();
    static ArrayList<String> directory13 = new ArrayList<String>();
    static ArrayList<String> directory14 = new ArrayList<String>();
   //static int mem=0;

    public void read() throws Exception{
        String list;

        try { 
            InputStream is = this.getClass().getResourceAsStream(absName);
            BufferedReader br=new BufferedReader(new InputStreamReader(is, "utf-8"));
            for (int i=0; i<MAX_WORDS; i++){
                list = br.readLine();
                
                if (list.length()==3){
                    directory3.add(list);
                }
                else if (list.length()==4){
                    directory4.add(list);
                }
                else if (list.length()==5){
                    directory5.add(list);
                }
                else if (list.length()==6){
                    directory6.add(list);
                }
                else if (list.length()==7){
                    directory7.add(list);
                }
                else if (list.length()==8){
                    directory8.add(list);
                }
                else if (list.length()==9){
                    directory9.add(list);
                }
                else if (list.length()==10){
                    directory10.add(list);
                }
                else if (list.length()==11){
                    directory11.add(list);
                }
                else if (list.length()==12){
                    directory12.add(list);
                }
                else if (list.length()==13){
                    directory13.add(list);
                }
                else if (list.length()==14){
                    directory14.add(list);
                }
            }
        
        }
        catch (Exception e){
            e.printStackTrace();
        }
    }
    static public String getDirectory(int n_dir){
        Random generator = new Random();
        //mem++;
        if (n_dir==3){
            return (directory3.get(generator.nextInt(directory3.size())));
        }
        if (n_dir==4){
            return (directory4.get(generator.nextInt(directory4.size())));
        }
        if (n_dir==5){
            return (directory5.get(generator.nextInt(directory5.size())));
        }
        if (n_dir==6){
            return (directory6.get(generator.nextInt(directory6.size())));
        }
        if (n_dir==7){
            return (directory7.get(generator.nextInt(directory7.size())));
        }
        if (n_dir==8){
            return (directory8.get(generator.nextInt(directory8.size())));
        }
        if (n_dir==9){
            return (directory9.get(generator.nextInt(directory9.size())));
        }
        if (n_dir==10){
            return (directory10.get(generator.nextInt(directory10.size())));
        }
        if (n_dir==11){
            return (directory11.get(generator.nextInt(directory11.size())));
        }
        if (n_dir==12){
            return (directory12.get(generator.nextInt(directory12.size())));
        }
        if (n_dir==13){
            return (directory13.get(generator.nextInt(directory13.size())));
        }
        if (n_dir==14){
            return (directory14.get(generator.nextInt(directory14.size())));
        }
        // Na sztuke
        return "";
    }
}