/**
* author Alex Rudniy
* excercise 8.4
*/
package hash;
import java.util.*;
import java.io.*;
public class Customers {
public static void main(String[] args) {
try {
BufferedReader in = new BufferedReader(new FileReader("input.txt"));
String delim = ":";
String line, field;
int count = 13;
String [] fields = new String[count];
HashSet hashName = new HashSet();
HashSet hashZip = new HashSet();
HashMap hashID = new HashMap();
while ((line = in.readLine()) != null) {
StringTokenizer st = new StringTokenizer(line,delim);
int i = 0;
while (st.hasMoreTokens()) {
field = st.nextToken();
fields[i] = field;
i++;
}
Customer cust = new Customer(fields[0],fields[1],fields[2],
fields[3],fields[4],fields[5],fields[6], Integer.parseInt(fields[7]),
fields[8],fields[9],fields[10],fields[11],Integer.parseInt(fields[12]));
hashName.add(fields[0]); // name
hashZip.add(fields[7]); // zipcode
hashID.put(fields[1], cust); // id --> customer
}
}
catch (IOException ex) {
//ex.printStackTrace();
System.out.println("An error has occured.");
}
}
}