JMU
logoWeatherBits.gif
Programming Assignment 5


1 Overview: WeatherBits is a (fictitious) company that develops weather-related software of various kinds. They have asked you to develop an application that can calculate wind chill values (for locations in North America) and display them on a map. Your work will be part of a larger product called WeatherBitmaps.

Wind chill values are calculated differently in different parts of the world (and have been calculated differently in the past). For the pusposes of this project, you must use the following formula that was developed for North American air temperatures at or below \(50^\circ\)F and wind speeds above \(3\)mph:

\[ w = 35.74 + 0.6215 \cdot t - 35.75 \cdot v^{0.16} + 0.4275 \cdot t \cdot v^{0.16} \]

where \(w\) denotes the wind chill value in degrees Farenheit, \(t\) denotes the air temperature in degrees Fahrenheit, and \(v\) denotes the velocity in miles per hour. For other temperatures and wind speeds, the wind chill value must be the air temperature.

2 Parts: This assignment is divided into several parts, each of which will be graded individually. You must satisfactorily complete all parts of this assignment in order. The later parts are based on the earlier parts and you may (indeed, should) use your answers to the earlier parts to complete the later parts.

a. A demonstration that you understand the problem. Click here to go to Blackboard. (Note: You may attempt this part of the assignment multiple times. You may not attempt the next part of the assignment until you have earned a grade of 70% on this part.)

b. A demonstration that you understand Java well enough to use it to complete the assignment. Click here to go to Blackboard. (Note: You may attempt this part of the assignment multiple times. You may not attempt the next part of the assignment until you have earned a grade of 80% on this part.)

c. A Java class (named Weather) that contains a function for calculating the wind chill value in North America (from a temperature measured in degrees Fahrenheit and a wind speed measured in miles per hour) Click here for the requirements. and a driver named WeatherDriver for testing this class.

d. A Java main class for calculating the wind chill value for several locations and displaying those values on a map. Click here for the requirements.

3 Getting Started: Before doing anything else, you should create a directory/folder (e.g., named pa5) that will hold all of the files for this assignment.

You must download the following Map class:

This class contains the following function:

setTemperature() which is passed a String containing the 4-character International Civil Aviation Organization (ICAO) code for the weather station and a double containing the temperature (which can either be the "raw" temperature or the wind chill value) at that location. This function does not return anything.

You must also download the following data files to your directory/folder for this assignment:

The first two data files contain weather data in a space-delimited format. The first field contains the 4-character ICAO code for the weather station, the second contains the temperature at that station (in degrees Farenheit), and the third contains the wind speed at that station (in mi/hr). Each line will contain exactly three fields. (You will need to write code that can read these files.)

The third data file contains information about each weather station, including its location. This file is used by the Map class. (You do not need to do anything with this file, and must not edit it.)

The fourth data file contains information about the geographic boundaries of the Commonwealth of Virginia. This file is used by the Map class. (You do not need to do anything with this file, and must not edit it.)

Finally, you must download the following updated version of the Text class:

In addition to the functions in the earlier version, this version also contains the following functions:

readNextLineFrom() which is passed a String containing a file name and returns a String containing the "next" line in that file.

thereAreMoreLinesIn() which is passed a String containing a file name and returns true if the file has more lines to be read and false otherwise.

splitAtSpaces() which is passed a String and returns a String[] containing all of the "words" in that String (where the "words" are defined by the spaces in the that String). For example, if splitAtSpaces() is passed a String containing "KSHD 5.0 13.0" it will return a String[] in which element 0 is "KSHD", element 1 is "5.0", and element 2 is "13.0".

toDouble() which is passed a String representation of a double and returns the corresponding double value. Note that, unlike toNonnegativeDouble(), this function will convert negative numbers. In addition, unlike toNonnegativeDouble(), this function returns the double constant named Double.NaN java.lang.Double#NaN if the String does not represent a number. You can test to see whether a particular double value equals Double.NaN using the Double.isNaN(double) java.lang.Double#isNaN(double) function which returns true if the double values is not a number and false otherwise.. You cannot use the == operator for this purpose.

4 Submitting Your Code: You must submit the code you write for Part c and Part d independently using Web-CAT (and the Blackboard attestation process). Specifically, after you complete your Weather class you must submit it using Web-CAT (and the Blackboard attestation process). Then, after you complete the ChillMapper class you must submit it (along with the Weather class) using Web-CAT (and the Blackboard attestation process).
5 Testing Your Code: You must test your Weather class and your ChillMapper class independently.


5.1 Testing the Weather Class
As mentioned in the description of the parts of this assignment, you must write a driver that you can use to test your Weather class. At a minimum, you must test it with the following values (and you should think about why each of these tests is relevant):
Temperature Wind Speed Wind Chill
20.2 17.4 5.47
40.0 10.0 33.64
51.0 20.0 51.00
20.0 3.0 20.00
-15.0 15.0 -38.61
50.0 10.0 46.04
-10.0 3.0 -10.0
49.9 4.0 48.75
50.0 3.1 49.59
5.0 13.0 -11.82

Note that the expected values above may only be accurate to 2 decimal places. You should think about how you will take that into account in your driver.

To reduce the burden on the Web-CAT server, after writing your own driver and testing your implementation of the Weather class, you should test your code using PA5cTestSuite.jar. As before, you will need to copy junit.jar to the working directory for this assignment. (PA5cTestSuite.jar uses the exact same tests cases as Web-CAT. So, if you code passes these tests it will pass the Web-CAT tests.) Note that neither PA5cTestSuite.jar nor Web-CAT will provide any hints if your code fails a test. You must use your driver to test and debug your code.


5.2 Testing the ChillMapper Class
You should first test your ChillMapper class using test cases that you create.

After testing your implementation using your test cases, too reduce the burden on the Web-CAT server, you should test your code using PA5dTestSuite.jar. This test suite does provide hints to help you debug your code.

6 Some Advice: Though the SRS for the ChillMapper does not have specific requirements about functions, you should spend a considerable amount of time designing this class (i.e., you should think about what functions you want to include). This class can be implemented in a variety of different ways, some of which are elegant and some of which are inelegant. You should not focus exclusively on getting your code working, you should also focus on making your code elegant. (Indeed, your grade will be based on the elegance of your solution. So, even if your code works, you might receive a very low grade if your solution is not well-designed.)

Also, even though this assignment has been divided into four parts, the last part is considerably more complicated than anything you have done thus far in this course (because you have to both design and implement your solution). Hence, you should start early. You will probably need all of the time between when the first part is due and when the last part is due to complete it.

7 A Suggested Plan: Obviously, you must start with the Weather class. Only after the Weather class has been implemented and tested should you start on the ChillMapper class. I recommend approaching this class as follows:
  1. Consider the case in which there are exactly three command-line arguments. Implement the code that handles this case and test it fully. (Hint: The code for this case will be very similar in many respects to the code you wrote for earlier programming assignments.)
  2. Consider the case in which there are a multiple of three command-line arguments. Implement the code that handles this case. Make sure you test this code to ensure that it properly handles non-numeric arguments. (Hint: This should involve a loop.) At this point, you should be able to delete the code for handling exactly three command-line arguments. In other words, that case is just a special version of this case.
  3. Consider the case in which there are no command-line arguments. Implement the code that handles this case. Make sure that you do not have code duplication. If you do, create a function (in the ChillMapper class), move the duplicative code to that function, and call that function. (Hint: This should involve another loop.)
  4. Consider the case in which there is one command-line argument. If your code properly handles no command-line arguments, this case should be straightforward. However, again make sure that you do not have duplicate code.
  5. Consider the other cases (i.e., two or more command-line arguments but not a multiple of three).
Going Further


Copyright 2013