import easyIO.*; import java.util.*; class Eliza { public static void main (String [] args) { Samtale sam = new Samtale(); sam.lesFraFil(); sam.snakk(); } } class Samtale { HashMap hash = new HashMap(); In tast = new In(); void lesFraFil() { In fil = new In("ord.txt"); while (!fil.lastItem()) { String s?keord = fil.inWord(); String svar = fil.inLine(); hash.put(s?keord, svar); } fil.close(); System.out.println("Antall ord lest: " + hash.size()); } void snakk() { while (true) { System.out.print("> "); boolean funnetMatch = false; do { String ord = tast.inWord().toLowerCase(); if (hash.containsKey(ord)) { String svar = (String) hash.get(ord); System.out.println(svar); funnetMatch = true; } } while (tast.hasNext() && !funnetMatch); if (!funnetMatch) { System.out.println("Interessant. Fortell mer."); } if (tast.hasNext()) { tast.readLine(); // T?mmer inputbufferet } } } }