Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ontarioMap;
- import postalCodePkg.PostalCodeEntry;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.nio.charset.StandardCharsets;
- import java.nio.file.Files;
- import java.nio.file.Path;
- import java.nio.file.Paths;
- /**
- * File name: Ghanem.Mishari.Assignment4
- * @author: Mishari Ghanem
- * Course: CST8284-531
- * Term: Winter2019
- * Assignment: Assignment4
- * Date: 4/10/2019 Purpose: Storing the data in a Map, then retrieve elements from the Map
- */
- public class OntarioMapTest {
- /**
- * main method
- *
- * @param args args
- */
- public static void main(String[] args) {
- Path file = Paths.get("./ottawa_postal_codes.csv");
- OntarioMap maps = new OntarioMap();
- BufferedReader reader;
- try {
- reader = Files.newBufferedReader(file, StandardCharsets.UTF_8);
- String line;
- while ((line = reader.readLine()) != null) {
- String[] address = line.split(",");
- maps.addToMap(address[0], address[1], address[2], address[3], address[4]);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- for (int i = 0; i < 10; i++) {
- String rand = PostalCodeEntry.getRandomPrefix();
- PostalCodeEntry code = maps.retrievePostalCode(rand);
- System.out.printf("Retrieving: %s\n", rand);
- if (code != null) {
- System.out.printf("\t%s\n", code);
- } else {
- System.out.printf("\tNOT found\n");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement