CS 206 - Introduction to Data Structures

Homework 2

ArrayList - Zipcode lookup

Due March 4 prior to 11:59:59 PM

Read the program design principles and code formatting standards carefully. You are expected to adhere to all stated standards.

Overview

This project uses ArrayList (use java.util.ArrayList) and object-oriented design with inheritance. The general idea is that the data about zip codes contains some information, but not all information and not every time. So, you will create classes with inheritance that allow you to store all the data available in the minimum possible space. All of the data must be stored in a single ArrayList. You will then query the array list in a manner much like that of the previous assignment.

Data

ziplocs.csv

/home/gtowell/Public/206/a3/ziplocs.csv
The lines in this file contain 12 comma-separated fields that look like this:
      "00705","STANDARD","AIBONITO","PR","PRIMARY",18.14,-66.26,"NA-US-PR-AIBONITO","false",,,
      "09005","MILITARY","APO","AE","PRIMARY",,,"EU-DE-WEISBADEN AAF OMDC","false",,,
      "10029","STANDARD","NEW YORK","NY","PRIMARY",40.71,-73.99,"NA-US-NY-NEW YORK","false",31490,48403,1050141146
The fields in each row are:

  1. zip code
  2. type -- ignored
  3. city name
  4. state abbreviation
  5. type 2 -- ignored
  6. Latitude
  7. Longitude
  8. long code -- ignored
  9. true or false -- ignored
  10. population 1
  11. population 2
  12. another number -- ignored

For this assignment we care about only: zip code, city name, state, latitude, longitude and population 2. Some lines are missing the longitude and latitude (like the second sample line), some are missing population, but all lines have the correct number of commas (11). There are no lines for which the longitude and latitude are not known but the population is known.

Given this final statement, the data falls into 3 groups: 1: those for which location and population are known, 2: those for which only location is known, 3: those for which neither location nor population is known. You first task is to design a set of java classes so that each of these groups can be stored in a instance that is capable of storing the available information, and no more. These java classes MUST be linked to each other using inheritance. For instance, if you define a class Place that stores group 3 data, then you might make a class

      public class LocatedPlace extends Place
to store group 2 data and another class
      public class PopulatedPlace extends LocatedPlace
to store group 1 data.

Requirements

Electronic Submissions

Your program will be graded based on how it runs on the department’s Linux server, not how it runs on your computer.

1. README:

The usual plain text file README
2. Source files:

3. Data files used:
ziplocs.csv
DO NOT INCLUDE:
Data files that are read from the class site.

The following steps for submission assume that you created a project directoryƟ named Assignment3 in the directory /home/YOU/cs206/

  1. Put the README file into the project directory (/home/YOU/cs206/Assignment3)
  2. Go to the directory /home/YOU/cs206/Assignment3/
  3. Enter /home/gtowell/bin/submit -c 206 -p 3 -d Assignment3
For more on using the submit script click here