/** * classe Main * classe eseguibile per prova della classe TR * Esercizio di programmazione del 6-Dic-2007 * * @author A. Luchetta */ import java.util.Scanner; import java.io.FileReader; import java.io.IOException; public class Main { public static void main(String[] args) throws IOException { final String END_OF_DATA = ""; Scanner in = new Scanner(new FileReader(args[0])); TR t = new TR(); while (in.hasNextLine()) { String line = in.nextLine(); Scanner tok = new Scanner(line); t.aggiungi(tok.next(), tok.next()); tok.close(); } in.close(); System.out.print("traduci? "); in = new Scanner(System.in); while (in.hasNextLine()) { String token = in.nextLine(); if (token.equals(END_OF_DATA)) break; String s = t.traduci(token); if (s != null) System.out.println(token + " " + s); else { System.out.println("***SCONOSCIUTA***"); String p = in.nextLine(); t.aggiungi(token, p); } System.out.print("traduci? "); } System.out.println("***STAMPA DEL DIZIONARIO***"); System.out.println(t); in.close(); } }