Question
--------------------------------- TestA4 ? public class TestA4 { public static void main(String[] args) { WordDataArrayList test = new WordDataArrayList(); try{ System.out.println(Testing WordDataArrayList basic operation: + ===========================================);
---------------------------------
TestA4 ?
public class TestA4 { public static void main(String[] args) { WordDataArrayList test = new WordDataArrayList(); try{ System.out.println("Testing WordDataArrayList basic operation: "+ "==========================================="); System.out.println("Should be empty list: "+test+" ----------"); test.add(99,"at"); System.out.println("Should be at(1 1)(99): "+test+" ----------"); test.add(103,"at"); System.out.println("Should be at(2 2)(99 103): "+test+" ----------"); test.add(103,"be"); System.out.println("Should be at(2 2)(99 103) and be(1 1)(103): "+test+" ----------"); } catch(Exception e){ System.out.println("Basic WordDataArrayList tests failed"); } try{ System.out.println(" Testing WordData equals and compareTo: "+ "======================================"); System.out.println("should be false: "+test.get(0).equals(test.get(1))); System.out.println("should be true: "+test.get(0).equals(test.get(0))); System.out.println("negative/positive may be reversed if \"be\" comes before \"at\":"); System.out.println("should be negative: "+test.get(0).compareTo(test.get(1))); System.out.println("should be 0: "+test.get(0).compareTo(test.get(0))); System.out.println("should be positive: "+test.get(1).compareTo(test.get(0))); } catch(Exception e){ System.out.println("WordData equals/compareTo tests failed"); } try{ System.out.println(" Testing WordDataArrayList additional operation: "+ "==============================================="); for(int i=0; i
} catch(Exception e){ System.out.println("WordScanner tests failed"); } } }
------------------------------------
TestWordScanner ?
public class TestWordScanner { public static final int minWordLength = 1; public static String line = "I'm sure _I_ shan't be able! I shall be a great deal too far off to trouble myself"+ " about you: you must manage the best way you can;--but I must be kind to them,' thought"+ " Alice, 'or perhaps they won't walk the way I want to go!"; public static void main(String[] args) { WordScanner getWords = new WordScanner(line,minWordLength); String word; do { word = getWords.nextWord(); if(word != null) System.out.println(word); } while(word != null); } }
Create a WordData class which will store all the information about one particular word in the concordance, including:* .The word itself (a string of lowercase letters only)- A list of all of the line numbers on which the word appears. This must be stored as arn ArrayListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started