Advertisement
Guest User

Untitled

a guest
Dec 10th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. public class MorseCode {
  5.  
  6. private HashMap<String, Character> helperMap = new HashMap<>();
  7. private TreeMap<Character, String> toCode = new TreeMap<>();
  8. private ArrayList<String> helperList = new ArrayList<>();
  9.  
  10.  
  11. private void encodeFile(String inputFileName, String outputFileName) throws Exception {
  12.  
  13. }
  14.  
  15. private void decodeFile(String inputFilename, String outputFileName) {
  16.  
  17. }
  18.  
  19. private void writeFile(String morse) {
  20. PrintWriter output = null;
  21. try {
  22. Scanner in = new Scanner(System.in);
  23.  
  24. // A printWriter works just like standard output
  25. output = new PrintWriter(new FileOutputStream("testPrintwriter"));
  26.  
  27. // We copy data from the keyboard to the file
  28. System.out.print("Enter some text");
  29. String data = in.nextLine();
  30. while (!data.equals("done")) {
  31. output.println(data);
  32.  
  33. System.out.print("Enter some more text (\"done\" to exit)");
  34. data = in.nextLine();
  35. }
  36. } catch (IOException e) {
  37. System.out.println(e);
  38. } finally {
  39. output.close();
  40. }
  41. }
  42.  
  43. private void readMorseCode(File name) {
  44. try {
  45. Scanner sc = new Scanner(name);
  46. while (sc.hasNextLine()) {
  47. Character c = sc.next().charAt(0);
  48. String s = sc.next();
  49. helperMap.put(s, c);
  50. }
  51. } catch (FileNotFoundException e) {
  52. e.printStackTrace();
  53. }
  54. }
  55.  
  56. TreeMap<String, Character> newMap = new TreeMap<>();
  57. Character sorry[] = {'E','T','I','A','N','M','S','U','R','W','D','K','G','O','H','V','F','L','P','J','B','X','C','Y','Z','Q'};
  58. private void makeList() {
  59. helperList.addAll(helperMap.keySet());
  60. Collections.sort(helperList);
  61. newMap.put("", ' ');
  62. for (String s : helperList) {
  63. for (int i = 0; i < s.length(); i++) {
  64. if (s.charAt(i) == '-'){
  65.  
  66. }
  67. }
  68. }
  69.  
  70. System.out.println(newMap);
  71. }
  72.  
  73.  
  74. public static void main(String[] args) {
  75. MorseCode mc = new MorseCode();
  76. mc.readMorseCode(new File("MorseCode.txt"));
  77. mc.makeList();
  78. System.out.println("hello world");
  79.  
  80. }
  81.  
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement