Homework 5: Due 10/4


This homework will help you get started on Project 1. Construct the City class (as described in Project 1 handout), but with just the default (0-argument) constructor. This involves:

  1. Defining all the data members correctly.
  2. Allocating memory for these data members correctly.
  3. Reading input from miles.dat and storing the information correctly in the data members.

Java provides many different ways of reading and parsing input. Consider using the StringTokenizer class for reading miles.dat. See this tutorial for a nice example of how a StringTokenizer is used. Also, consult StringTokenizer java documentation. You are not required to use the StringTokenizer class; the StreamTokenizer class, and the Scanner class are other possibilities.

Add a main method to the City class that tests your constructor carefully. You may have to add some primitive output methods to your class to dump out the data members, so that you can spot check your output to convince yourself that your constructor is working correctly.

Submit City.java and City.readme. The "readme" file should describe how to read and interpret the output produced.