Suppose that you are getting ready to graduate and you want to decide whether you should take the job in Anchorage, Alaska, Chicago, Illinois, Riyadh, Saudi Arabia, or one of several other cities (as a graduate of UNI's computer science department you are very much in demand!). One of your deciding factors will be the weather in those cities (I will leave it up to you to decide what is "favorable" weather). To compare the year round weather in several different cities, you decide to write a visualization program called WeatherSurfer.
WeatherSurfer is a program that reads and displays historical weather data. It knows the average monthly temperature for a variety of cities from the US and Saudi Arabia (other countries could easily be loaded into the system but that data isn't distributed with this assignment). The user enters a city/state or city/country pair, and the program graphs the average temperature for each of the twelve months.
Here is a screenshot of one WeatherSurfer program in action:
You can run a demonstration version of a WeatherSurfer program by trying out this applet (this applet only contains five cities - present in small.txt mentioned below).
The demonstration is just an example. You do not have to produce an interface that looks identical to this one.
Write your program as a collection of the following classes:
WeatherSurfer consists only of a main() method. This method should first create a WeatherFileReader to read weather data from a text file. The user can specify the file name as a command-line argument, or she can rely on the default value of weather.txt. It should then creates a WeatherSurferFrame and displays the frame on the screen.
Some sample weather data files are available in weather_data.zip
This includes the following files containing raw data, all extracted from http://www.weatherbase.com/
small.txt - the smallest, containing only five cities(Cedar Falls, Waterloo, Chicago, Anchorage, and Riyadh).
A WeatherSurferFrame consists of an interaction panel at the bottom of the window and a graph panel at the top.
A WeatherFileReader reads a file of weather data into an ArrayList of WeatherHistory records. Each line in a file of weather data contains fifteen tokens:
An instance of WeatherHistory is kind of like a single record in a database. Each instance knows which city and state/country it is storing information about and the average temperature for that location for each of the twelve months.
Finally, create a readme.txt file that explains the design of your program and lists all of its Java files, in the order they appear in your print-out
The version of WeatherSurfer shown in the screenshot at the top of the screen and distributed in the .jar file above both have functionality that you are not required to provide. Your program SHOULD provide the following minimum specs:
Things you may do for extra credit
While the order in the "tasks" section implies that you should create WeatherSurfer first and WeatherHistory last, I would, in fact, completely reverse the order on this list. Begin by creating the class WeatherHistory which is a "database record" as described. Then create the WeatherFileReader class which reads a file of cities to create an ArrayList of all WeatherHistory elements storing names [Hint, this is SOMETHING like how BankAccountReader took a name of a file and populated a BankAccount with Transactions read in from a file]. At this point you might set up WeatherSurfer to just run a few tests on the resulting ArrayList so that you know you can "search" the list for names and get back their rankings.
Finally, you should create the WeatherSurferFrame to be your View/Controller using the ArrayList "model" returned by WeatherFileReader.
As always, take small steps. I suggest that you take steps at least this small:
void setResizable(boolean resizable)
By the due date and time, submit the files
Be sure that your submission follows all homework submission requirements.
This assignment was based on an assignments made by Dr. Gene Wallingford and Dr. Nick Parlante