annotate kopieckreta/src/MyResource.java @ 12:24d60bdea349

ClonneChannel
author prymula <prymula76@outlook.com>
date Thu, 08 Feb 2024 20:24:27 +0100
parents 2787f5e749ae
children 489244127359
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
prymula <prymula76@outlook.com>
parents:
diff changeset
2 Nie mieszać z java.awt.* (!!!)
prymula <prymula76@outlook.com>
parents:
diff changeset
3 */
prymula <prymula76@outlook.com>
parents:
diff changeset
4 package src;
prymula <prymula76@outlook.com>
parents:
diff changeset
5
prymula <prymula76@outlook.com>
parents:
diff changeset
6 import java.io.IOException;
prymula <prymula76@outlook.com>
parents:
diff changeset
7 import java.io.InputStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
8 import java.io.PrintStream;
prymula <prymula76@outlook.com>
parents:
diff changeset
9 import java.io.BufferedReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
10 import java.io.InputStreamReader;
prymula <prymula76@outlook.com>
parents:
diff changeset
11
prymula <prymula76@outlook.com>
parents:
diff changeset
12 import java.util.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
13 import java.lang.*;
prymula <prymula76@outlook.com>
parents:
diff changeset
14
prymula <prymula76@outlook.com>
parents:
diff changeset
15
prymula <prymula76@outlook.com>
parents:
diff changeset
16 class MyResource {
prymula <prymula76@outlook.com>
parents:
diff changeset
17 final int MAX_WORDS=67656;
prymula <prymula76@outlook.com>
parents:
diff changeset
18
prymula <prymula76@outlook.com>
parents:
diff changeset
19 public void MyResource()
prymula <prymula76@outlook.com>
parents:
diff changeset
20 {
prymula <prymula76@outlook.com>
parents:
diff changeset
21 }
prymula <prymula76@outlook.com>
parents:
diff changeset
22 private static final String absName = "/slownik.txt";
prymula <prymula76@outlook.com>
parents:
diff changeset
23 // TODO - to jest mniej eleganckie;
prymula <prymula76@outlook.com>
parents:
diff changeset
24 static ArrayList<String> directory3 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
25 static ArrayList<String> directory4 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
26 static ArrayList<String> directory5 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
27 static ArrayList<String> directory6 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
28 static ArrayList<String> directory7 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
29 static ArrayList<String> directory8 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
30 static ArrayList<String> directory9 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
31 static ArrayList<String> directory10 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
32 static ArrayList<String> directory11 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
33 static ArrayList<String> directory12 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
34 static ArrayList<String> directory13 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
35 static ArrayList<String> directory14 = new ArrayList<String>();
prymula <prymula76@outlook.com>
parents:
diff changeset
36 //static int mem=0;
prymula <prymula76@outlook.com>
parents:
diff changeset
37
prymula <prymula76@outlook.com>
parents:
diff changeset
38 public void read() throws Exception{
prymula <prymula76@outlook.com>
parents:
diff changeset
39 String list;
prymula <prymula76@outlook.com>
parents:
diff changeset
40
prymula <prymula76@outlook.com>
parents:
diff changeset
41 try {
prymula <prymula76@outlook.com>
parents:
diff changeset
42 InputStream is = this.getClass().getResourceAsStream(absName);
prymula <prymula76@outlook.com>
parents:
diff changeset
43 BufferedReader br=new BufferedReader(new InputStreamReader(is, "utf-8"));
prymula <prymula76@outlook.com>
parents:
diff changeset
44 for (int i=0; i<MAX_WORDS; i++){
prymula <prymula76@outlook.com>
parents:
diff changeset
45 list = br.readLine();
prymula <prymula76@outlook.com>
parents:
diff changeset
46
prymula <prymula76@outlook.com>
parents:
diff changeset
47 if (list.length()==3){
prymula <prymula76@outlook.com>
parents:
diff changeset
48 directory3.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
49 }
prymula <prymula76@outlook.com>
parents:
diff changeset
50 else if (list.length()==4){
prymula <prymula76@outlook.com>
parents:
diff changeset
51 directory4.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
52 }
prymula <prymula76@outlook.com>
parents:
diff changeset
53 else if (list.length()==5){
prymula <prymula76@outlook.com>
parents:
diff changeset
54 directory5.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
55 }
prymula <prymula76@outlook.com>
parents:
diff changeset
56 else if (list.length()==6){
prymula <prymula76@outlook.com>
parents:
diff changeset
57 directory6.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
58 }
prymula <prymula76@outlook.com>
parents:
diff changeset
59 else if (list.length()==7){
prymula <prymula76@outlook.com>
parents:
diff changeset
60 directory7.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
61 }
prymula <prymula76@outlook.com>
parents:
diff changeset
62 else if (list.length()==8){
prymula <prymula76@outlook.com>
parents:
diff changeset
63 directory8.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
64 }
prymula <prymula76@outlook.com>
parents:
diff changeset
65 else if (list.length()==9){
prymula <prymula76@outlook.com>
parents:
diff changeset
66 directory9.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
67 }
prymula <prymula76@outlook.com>
parents:
diff changeset
68 else if (list.length()==10){
prymula <prymula76@outlook.com>
parents:
diff changeset
69 directory10.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
70 }
prymula <prymula76@outlook.com>
parents:
diff changeset
71 else if (list.length()==11){
prymula <prymula76@outlook.com>
parents:
diff changeset
72 directory11.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
73 }
prymula <prymula76@outlook.com>
parents:
diff changeset
74 else if (list.length()==12){
prymula <prymula76@outlook.com>
parents:
diff changeset
75 directory12.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
76 }
prymula <prymula76@outlook.com>
parents:
diff changeset
77 else if (list.length()==13){
prymula <prymula76@outlook.com>
parents:
diff changeset
78 directory13.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
79 }
prymula <prymula76@outlook.com>
parents:
diff changeset
80 else if (list.length()==14){
prymula <prymula76@outlook.com>
parents:
diff changeset
81 directory14.add(list);
prymula <prymula76@outlook.com>
parents:
diff changeset
82 }
prymula <prymula76@outlook.com>
parents:
diff changeset
83 }
prymula <prymula76@outlook.com>
parents:
diff changeset
84
prymula <prymula76@outlook.com>
parents:
diff changeset
85 }
prymula <prymula76@outlook.com>
parents:
diff changeset
86 catch (Exception e){
prymula <prymula76@outlook.com>
parents:
diff changeset
87 e.printStackTrace();
prymula <prymula76@outlook.com>
parents:
diff changeset
88 }
prymula <prymula76@outlook.com>
parents:
diff changeset
89 }
prymula <prymula76@outlook.com>
parents:
diff changeset
90 static public String getDirectory(int n_dir){
prymula <prymula76@outlook.com>
parents:
diff changeset
91 Random generator = new Random();
prymula <prymula76@outlook.com>
parents:
diff changeset
92 //mem++;
prymula <prymula76@outlook.com>
parents:
diff changeset
93 if (n_dir==3){
prymula <prymula76@outlook.com>
parents:
diff changeset
94 return (directory3.get(generator.nextInt(directory3.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
95 }
prymula <prymula76@outlook.com>
parents:
diff changeset
96 if (n_dir==4){
prymula <prymula76@outlook.com>
parents:
diff changeset
97 return (directory4.get(generator.nextInt(directory4.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
98 }
prymula <prymula76@outlook.com>
parents:
diff changeset
99 if (n_dir==5){
prymula <prymula76@outlook.com>
parents:
diff changeset
100 return (directory5.get(generator.nextInt(directory5.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
101 }
prymula <prymula76@outlook.com>
parents:
diff changeset
102 if (n_dir==6){
prymula <prymula76@outlook.com>
parents:
diff changeset
103 return (directory6.get(generator.nextInt(directory6.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
104 }
prymula <prymula76@outlook.com>
parents:
diff changeset
105 if (n_dir==7){
prymula <prymula76@outlook.com>
parents:
diff changeset
106 return (directory7.get(generator.nextInt(directory7.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
107 }
prymula <prymula76@outlook.com>
parents:
diff changeset
108 if (n_dir==8){
prymula <prymula76@outlook.com>
parents:
diff changeset
109 return (directory8.get(generator.nextInt(directory8.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
110 }
prymula <prymula76@outlook.com>
parents:
diff changeset
111 if (n_dir==9){
prymula <prymula76@outlook.com>
parents:
diff changeset
112 return (directory9.get(generator.nextInt(directory9.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
113 }
prymula <prymula76@outlook.com>
parents:
diff changeset
114 if (n_dir==10){
prymula <prymula76@outlook.com>
parents:
diff changeset
115 return (directory10.get(generator.nextInt(directory10.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
116 }
prymula <prymula76@outlook.com>
parents:
diff changeset
117 if (n_dir==11){
prymula <prymula76@outlook.com>
parents:
diff changeset
118 return (directory11.get(generator.nextInt(directory11.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
119 }
prymula <prymula76@outlook.com>
parents:
diff changeset
120 if (n_dir==12){
prymula <prymula76@outlook.com>
parents:
diff changeset
121 return (directory12.get(generator.nextInt(directory12.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
122 }
prymula <prymula76@outlook.com>
parents:
diff changeset
123 if (n_dir==13){
prymula <prymula76@outlook.com>
parents:
diff changeset
124 return (directory13.get(generator.nextInt(directory13.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
125 }
prymula <prymula76@outlook.com>
parents:
diff changeset
126 if (n_dir==14){
prymula <prymula76@outlook.com>
parents:
diff changeset
127 return (directory14.get(generator.nextInt(directory14.size())));
prymula <prymula76@outlook.com>
parents:
diff changeset
128 }
prymula <prymula76@outlook.com>
parents:
diff changeset
129 // Na sztukę
prymula <prymula76@outlook.com>
parents:
diff changeset
130 return "";
prymula <prymula76@outlook.com>
parents:
diff changeset
131 }
prymula <prymula76@outlook.com>
parents:
diff changeset
132 }