Given the following java code, produce an HLD hierarchy and assess the coupling and cohesion in the design. Suggest possible enhancements to the design. import javax.swing.*; import java.io.*; import...

Given the following java code, produce an HLD hierarchy and assess the coupling and cohesion in the design. Suggest possible enhancements to the design. import javax.swing.*; import java.io.*; import java.util.*; class SPC { static String word; // files for input and output static PrintWriter wwf; static BufferedReader tf; static BufferedReader df; static StringTokenizer words; static String line  ; static String dict []  new String[10000]; static int index  0; public static void main(String args[]) throws IOException { String line ““; boolean flag1, flag2; init(); while ((word  getWord()) ! null) { flag1  validate(word); if (flag1  false) { flag2  checkWithUser(word); if (flag2  true) addToDict(word); else addToWWF(word); } } finalizer(); } static String getWord() throws IOException { if (words.hasMoreTokens() false) { line  tf.readLine(); if (line ! null) words  new StringTokenizer(line); else return null; return words.nextToken(); } else return words.nextToken(); } static void init() throws IOException { wwf  new PrintWriter(new FileWriter(“wwf.out”)); tf  new BufferedReader(new FileReader(“tf.in”)); df  new BufferedReader(new FileReader(“df.in”)); line  tf.readLine(); words  new StringTokenizer(line); String line1 ““; while ((line1df.readLine() ) ! null) dict[index]  line1; } static void finalizer()throws IOException { df.close(); PrintWriter df  new PrintWriter(new FileWriter(“df.in”)); Arrays.sort(dict,0,index); // load array back in dictionary file for (int c0;c  index;c) df.println(dict[c]); System.out.println(“DONE”); df.close(); wwf.close(); } static boolean validate(String w) { for (int i0; i  index; i) if (dict[i].equals(w)) return true; return false; } static boolean checkWithUser(String w) { String answer  JOptionPane.showInputDialog (“Is the word “  w “ valid ? Enter T or F ?”);; if (answer.equals(“T”)) return true; else return false; } static void addToDict(String word) { dict[index]  word; } static void addToWWF(String word) { wwf.println(word); }

May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here