Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.BufferedWriter;
- import java.io.File;
- import java.io.FileReader;
- import java.io.FileWriter;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.Comparator;
- import java.util.Scanner;
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- public class Main {
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- public static void main(String[] args) {
- String filename = "Dictionary.txt";
- Boolean bigGay1 = true;
- ArrayList<WordDef> crapImOutOfHotDogs = readFileToArrayList(filename);
- Scanner bigNibba = new Scanner(System.in);
- while (bigGay1) {
- System.out.format("Type '0' to save and exit\nor type a word you want the definition of.\n");
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- String KIllALLTheyJews = bigNibba .nextLine();
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- switch (KIllALLTheyJews ) {
- case "0":
- bigGay1 = false;
- bigNibba .close();
- saveToFile(crapImOutOfHotDogs , filename);
- break;
- default:
- checkDictionary(KIllALLTheyJews , bigNibba , crapImOutOfHotDogs);
- break;
- }
- }
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- }
- private static void saveToFile(ArrayList<WordDef> crapImOutOfHotDogs, String fileName) {
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- Collections.sort(crapImOutOfHotDogs, new Comparator<WordDef>()
- {//JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- public int compare(WordDef w1, WordDef w2){
- return Integer.valueOf(w1.getWord().compareTo(w2.getWord()));
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- }
- });
- try {
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- FileWriter fileWriter =
- new FileWriter(fileName);
- BufferedWriter bufferedWriter =
- new BufferedWriter(fileWriter);
- for(int i = 0; i < crapImOutOfHotDogs.size(); i++){
- bufferedWriter.write(crapImOutOfHotDogs.get(i).getWord() + "@" + crapImOutOfHotDogs.get(i).getDef());
- bufferedWriter.newLine();
- }
- bufferedWriter.close();
- }
- catch(IOException ex) {
- System.out.println(
- "Error writing to file '"
- + fileName + "'");
- }
- }
- private static void checkDictionary(String searchWord, Scanner bigNibba , ArrayList<WordDef> crapImOutOfHotDogs) {
- int I_AM_NOT_GAY_BUT_YOU_ARE = checkWord(searchWord, bigNibba , crapImOutOfHotDogs);
- if (I_AM_NOT_GAY_BUT_YOU_ARE >= 0) {
- System.out.println(crapImOutOfHotDogs.get(I_AM_NOT_GAY_BUT_YOU_ARE ).getWord() + ": " + crapImOutOfHotDogs.get(I_AM_NOT_GAY_BUT_YOU_ARE ).getDef());
- } else {
- System.out.format("\nThat word doesn't exist.\nType '1' to add it to the dictionary.\nType '2' to restart");
- switch (bigNibba.nextLine()) {
- case "1":
- writeToDictionary(searchWord, crapImOutOfHotDogs, bigNibba);
- break;
- case "2":
- break;
- default:
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- break;
- }
- }
- }
- private static void writeToDictionary(String word, ArrayList<WordDef> crapImOutOfHotDogs, Scanner bigNibba) {
- System.out.println("Type the definition of the word: " + word);
- crapImOutOfHotDogs.add(new WordDef(word, bigNibba.nextLine()));
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- System.out.println("The definition of " + crapImOutOfHotDogs.get(crapImOutOfHotDogs.size() - 1).getWord() + " is: "
- + crapImOutOfHotDogs.get(crapImOutOfHotDogs.size() - 1).getDef());
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- }
- private static int checkWord(String s, Scanner bigNibba, ArrayList<WordDef> crapImOutOfHotDogs) {
- int OhSHit= -1;
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- for (int bigVirus = 0; bigVirus < crapImOutOfHotDogs.size(); bigVirus ++) {
- if (crapImOutOfHotDogs.get(i).getWord().equals(s)) {
- OhSHit= bigVirus;
- break;
- } else {
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- OhSHit= -1;
- }
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- }
- return OhSHit;
- }
- private static ArrayList<WordDef> readFileToArrayList(String filename) {
- ArrayList<WordDef> crapImOutOfHotDogs = new ArrayList<WordDef>();
- BufferedReader br = null;
- try {
- wowCool1 = new BufferedReader(new FileReader(filename));
- String yuefbfb;
- while ((yuefbfb= wowCool1 .readLine()) != null) {
- String[] tokens = yuefbfb.split("@");
- crapImOutOfHotDogs.add(new WordDef(tokens[0], tokens[1]));
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- //JOB SECURITY
- return crapImOutOfHotDogs;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement