/* File: Concordance.java * Author: Wayne Snyder * Email: waysnyder@gmail.com * Date: Aug 8 2020 * Purpose: Unit Tests for HW 06, CS 112, Aug 9 2020 */ public class Concordance implements Concordable { public Concordance(String text) { // Your code here } // Your code here // Unit tests, see end of file for correct output public static void main(String [] args) { System.out.println("\nSimple Test\n"); //0: A b C //1: D E A F e A //2: F d r a String sampleText="A b C\n D E A F e A \n F d r a \n"; Concordable C = new Concordance(sampleText); C.printConcordance(); System.out.println("\nShould print out:\na: 0,1,2 "); C.lookup("a"); System.out.println("\nShould print out:\ne: 1"); C.lookup("E"); // not a typo, you must convert everything to lower case! System.out.println("\nShould print out:\nq:"); C.lookup("q"); System.out.println(); System.out.println("\nHaiku Test\n"); String Haiku = "Arms folded\nTo the moon\nAmong the cows.\n"; Concordable D = new Concordance(Haiku); D.printConcordance(); System.out.println("\nShould print out:\nthe: 1,2"); D.lookup("the"); System.out.println(); System.out.println("\nGettysburg Address Test\n"); String Gettysburg = "Four score and seven years ago our fathers brought forth on this continent, a new nation, conceived in Liberty, and dedicated to the proposition that all men are created equal.\n" + "Now we are engaged in a great civil war, testing whether that nation, or any nation so conceived and so dedicated, can long endure.\n" + "We are met on a great battlefield of that war.\n" + "We have come to dedicate a portion of that field, as a final resting place for those who here gave their lives that that nation might live.\n" + "It is altogether fitting and proper that we should do this.\n" + "But, in a larger sense, we can not dedicate, we can not consecrate, we can not hallow, this ground.\n" + "The brave men, living and dead, who struggled here, have consecrated it, far above our poor power to add or detract.\n" + "The world will little note, nor long remember what we say here, but it can never forget what they did here.\n" + "It is for us the living, rather, to be dedicated here to the unfinished work which they who fought here have thus far so nobly advanced.\n" + "It is rather for us to be here dedicated to the great task remaining before us, that from these honored dead we take increased devotion to that " + "cause for which they gave the last full measure of devotion, that we here highly resolve that these dead shall not have died in vain, " + "that this nation, under God, shall have a new birth of freedom, and that government of the people, by the people, for the people, shall not perish from the earth.\n"; Concordable E = new Concordance(Gettysburg); E.printConcordance(); System.out.println("\nShould print out:\ndedicated: 0,1,8,9"); E.lookup("dedicated"); } } /* Here is what you should get for this unit test: Simple Test a: 0,1,2 b: 0 c: 0 d: 1,2 e: 1 f: 1,2 r: 2 Should print out: a: 0,1,2 a: 0,1,2 Should print out: e: 1 e: 1 Should print out: q: q: Haiku Test among: 2 arms: 0 cows: 2 folded: 0 moon: 1 the: 1,2 to: 1 Should print out: the: 1,2 the: 1,2 Gettysburg Address Test a: 0,1,2,3,5,9 above: 6 add: 6 advanced: 8 ago: 0 all: 0 altogether: 4 and: 0,1,4,6,9 any: 1 are: 0,1,2 as: 3 battlefield: 2 be: 8,9 before: 9 birth: 9 brave: 6 brought: 0 but: 5,7 by: 9 can: 1,5,7 cause: 9 civil: 1 come: 3 conceived: 0,1 consecrate: 5 consecrated: 6 continent: 0 created: 0 dead: 6,9 dedicate: 3,5 dedicated: 0,1,8,9 detract: 6 devotion: 9 did: 7 died: 9 do: 4 earth: 9 endure: 1 engaged: 1 equal: 0 far: 6,8 fathers: 0 field: 3 final: 3 fitting: 4 for: 3,8,9 forget: 7 forth: 0 fought: 8 four: 0 freedom: 9 from: 9 full: 9 gave: 3,9 god: 9 government: 9 great: 1,2,9 ground: 5 hallow: 5 have: 3,6,8,9 here: 3,6,7,8,9 highly: 9 honored: 9 in: 0,1,5,9 increased: 9 is: 4,8,9 it: 4,6,7,8,9 larger: 5 last: 9 liberty: 0 little: 7 live: 3 lives: 3 living: 6,8 long: 1,7 measure: 9 men: 0,6 met: 2 might: 3 nation: 0,1,3,9 never: 7 new: 0,9 nobly: 8 nor: 7 not: 5,9 note: 7 now: 1 of: 2,3,9 on: 0,2 or: 1,6 our: 0,6 people: 9 perish: 9 place: 3 poor: 6 portion: 3 power: 6 proper: 4 proposition: 0 rather: 8,9 remaining: 9 remember: 7 resolve: 9 resting: 3 say: 7 score: 0 sense: 5 seven: 0 shall: 9 should: 4 so: 1,8 struggled: 6 take: 9 task: 9 testing: 1 that: 0,1,2,3,4,9 the: 0,6,7,8,9 their: 3 these: 9 they: 7,8,9 this: 0,4,5,9 those: 3 thus: 8 to: 0,3,6,8,9 under: 9 unfinished: 8 us: 8,9 vain: 9 war: 1,2 we: 1,2,3,4,5,7,9 what: 7 whether: 1 which: 8,9 who: 3,6,8 will: 7 work: 8 world: 7 years: 0 Should print out: dedicated: 0,1,8,9 dedicated: 0,1,8,9 Process finished with exit code 0 */