/** * SortedContainerTester1 * Classe di prova * @author Adriano Luchetta * @version 7-Nov-2003 * @version 20-Nov-2004 * @version 16-Nov-2006 */ import java.util.Scanner; import java.util.NoSuchElementException; public class SortedContainerTester1 { public static void main(String[] args) { final char COMMENT_CHARACTER = '*'; SortedContainer list = new SortedContainer(); Scanner in = new Scanner(System.in); // acquisizione dati int lineCounter = 0; String line = ""; while (in.hasNextLine()) { lineCounter++; line = in.nextLine(); if (line.charAt(0) != COMMENT_CHARACTER) { Scanner tok = new Scanner(line); tok.useDelimiter("[:]+"); try { String nome = tok.next(); int matricola = tok.nextInt(); list.add(new Studente(nome, matricola)); } catch (NoSuchElementException e) { System.out.println(">>> riga " + lineCounter + " errata: " + line); } tok.close(); } } in.close(); System.out.println("\n*** ELENCO STUDENTI IN ORDINE DI MATRICOLA DECRESCENTE"); while (!list.isEmpty()) System.out.println((Studente)list.removeMax()); } }