view kopieckreta/src/MyResource.java @ 22:b0c59d056e73

colorsmemory - typo
author Przemyslaw <prymula76@outlook.com>
date Sun, 31 Mar 2024 22:53:32 +0200
parents 2787f5e749ae
children 489244127359
line wrap: on
line source

/* 
    Nie mieszać  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 sztukę
        return "";
    }
}