CS 206: Data Structures
Exercise#13
Due on Tuesday, April 1
In Exercise 12, you created an application that reads a given file containing weather data and defined a class called, DailyWeather whose objects hold data for a single day. Look closely at your definition of DailyWeather. Did you define its data members as show below?
public class DailyWeather { private int month; private int day; private int year; private int high; private int low; private int/float precip; private int/float snowfall; ... } // DailyWeather
If you did, you ignored the first tenet of data abstraction...abstract conceptually alike data into a sigle abstraction. In the above example, the date (month, day, year) is a conceptual entity that is very different from the rest of the data. You should define a separate class (say Date) for this purpose and then use composition to define the DailyWeather class. Keep all methods and operations relating to the Date class separate from the operations need on the weather data.
In the next version of your program you will do the following:
In order to accomplish this, you will need to store all the data in a list. This time use the LinkedList class from the java.util package. The interface is the same as the one you implemented.
Hand in a printout of your complete program along with the output for the following:
Notes:
Implement the features one at a time, testing for each implemented feature each time. Java does have a built-in Date (and Calendar) classes, but we will not use them here. Use your own. In doing the computations, remember that in certain cases, the data is not available (or is insignificant). Your program your account for these (i.e. ignore them and not inlcude them in computing avarages). Your prigram will be graded based on correctness.
Start early. There are many individual components to this program. While each one of them is fairly easy, it is not advised that you try and finish it all in a single session.