import java.io.*; import java.util.Scanner; public class ListTester { public static void main(String[] args) { System.out.println("List tester."); // Make some list items. ListItem item1 = new ListItem(); item1.setName("+2 ring"); item1.setDesc("precious"); item1.setCost(42.2112); item1.setNext(null); // Redundant, but safe. ListItem item2 = new ListItem(); item2.setName("Cloak of Doom"); item2.setDesc("Scary"); item2.setCost(666); item2.setNext(null); // Still redundant. Still safe. ListItem item3 = new ListItem(); item3.setName("broad sword"); item3.setDesc("sharp"); item3.setCost(12); item3.setNext(null); // Still redundant. Still safe. // Make the list manager. ListMan lm1 = new ListMan(); lm1.setName("Magic Items"); lm1.setDesc("These are some of my favorite things."); // Put items in the list. lm1.add(item1); lm1.add(item2); lm1.add(item3); final String fileName = "magic.txt"; File myFile = new File(fileName); try { Scanner input = new Scanner(myFile); while (input.hasNext()) { String itemName = input.nextLine(); // System.out.println(line); ListItem fileItem = new ListItem(); fileItem.setName(itemName); fileItem.setCost(27.64); fileItem.setNext(null); // Still redundant. Still safe. lm1.add(fileItem); } input.close(); } catch (FileNotFoundException ex) { System.out.println("File not found. " + ex.toString()); } // System.out.println("at EOF"); // Display the list. System.out.println(lm1.toString()); } }