import java.util.Random; /** * Drive the Shakespeare example * @author gtowell * Created: Sep 28, 2020 */ public class Main { public static void main(String[] args) { Shak shak = new Shak("shak.outt"); Random r = new Random(); // get 10 random lines for (int i=0; i<10; i++) { System.out.println(i + " " + shak.getLineNo(r.nextInt(shak.size()*2))); } String[] ll = "mista kurtz is dead a penny for old guy".split(" "); // get a line containing a word in the above string for (String wrd : ll) { Line l = shak.firstLineContaining(wrd); if (l!=null) System.out.println(wrd+"=="+l); } } }