Loading src/edu/bu/ec504/hw2p3/Main.java +20 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package edu.bu.ec504.hw2p3; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; import java.util.HashSet; public class Main { Loading @@ -12,9 +13,22 @@ public class Main { public static void main(String[] args) { FindSimilar myFindSimilar = new MyFindSimilar(); // thanks ChatGPT for the idea of how to convert a string into a BufferedReader String testStr = """ oast oath ogre onyx oss --- ores --- """; StringReader strReader = new StringReader(testStr); // Read and process input BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); new BufferedReader(strReader); try { // read in dictionary for ( Loading @@ -31,14 +45,15 @@ public class Main { !line.equals(DELIMITER); line = reader.readLine()) { System.out.println(myFindSimilar.closestWord(line)); int result = myFindSimilar.closestWord(line); System.out.println("Response: "+result); if (result!=2) throw new RuntimeException("Incorrect return value - expecting 2."); } } catch (IOException e) { System.out.println("Sorry ... something went wrong."); e.printStackTrace(); System.exit(-1); throw new RuntimeException("Something went wrong: "+e); } Loading Loading
src/edu/bu/ec504/hw2p3/Main.java +20 −5 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ package edu.bu.ec504.hw2p3; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringReader; import java.util.HashSet; public class Main { Loading @@ -12,9 +13,22 @@ public class Main { public static void main(String[] args) { FindSimilar myFindSimilar = new MyFindSimilar(); // thanks ChatGPT for the idea of how to convert a string into a BufferedReader String testStr = """ oast oath ogre onyx oss --- ores --- """; StringReader strReader = new StringReader(testStr); // Read and process input BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); new BufferedReader(strReader); try { // read in dictionary for ( Loading @@ -31,14 +45,15 @@ public class Main { !line.equals(DELIMITER); line = reader.readLine()) { System.out.println(myFindSimilar.closestWord(line)); int result = myFindSimilar.closestWord(line); System.out.println("Response: "+result); if (result!=2) throw new RuntimeException("Incorrect return value - expecting 2."); } } catch (IOException e) { System.out.println("Sorry ... something went wrong."); e.printStackTrace(); System.exit(-1); throw new RuntimeException("Something went wrong: "+e); } Loading