JMU
logoDukeDash.png
Programming Assignment 2


1 Overview: President Alger is quite pleased with your initial work on DukeDash and is very excited about the attention that this kind of technology is starting to get (as, for example, in a story in The New York Times ). As a result, he wants you to extend the prototype. In particular, he now wants you to add the ability to display trip information.

So, as before, DukeDash will be given the current speed in mi/hr, convert it to km/hr, and display the speed in km/hr. Now, DukeDash will also be given the distance traveled during the current trip in ft and the duration of the current trip in hr and it must calculate and display the average trip speed in both mi/hr and km/hr.

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. (Note: Unlike the previous assignment, you may need to expand on and/or modify the textual algorithms when developing the Java implementations.)

a. A textual version of an algorithm for converting a distance in ft to a distance in mi and a textual version of an algorithm for converting a trip distance measured in ft and a trip duration measured in hr to trip speeds measured in both mi/hr and km/hr. 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 100% on this part.)

b. An exercise on integer division, type casting and implicit numeric promotion. 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.1. A modified version of your Java class named Converter that now has the ability to convert distances measured in whole feet to equivalent distances measured in miles. Click here for the requirements.

c.2. A Java application that is: given command-line strings containing a real-valued speed in mi/hr, an integer-valued trip distance in ft, and a trip duration in hr; converts the strings as appropriate; performs the necessary calculations; and displays the results. Click here for the requirements.

3 Getting Started on the Programming: Before doing anything else, you should create a directory/folder (e.g., named pa2) that will hold all of the files for this assignment. Next, you should copy your Converter.java and the provided Text.class and Dashboard.class to the directory you just created.

After that, you must test your Conveter class (since you have not yet tested it). You must use the same test cases you used to test the SpeedPrinter class. To facilitate the process, you may use the following program:

You should read and understand this program before using it.

4 Getting Help: This assignment is a straightforward extension of Programming Assignment 1 (which you should have a working version of from Part D). Hence, the lab assistants will only provide limited help on this assignment. If you are having problems, they will try and help you understand what you are doing wrong. Other than that, they will not provide much help.
5 Recommended Process for the Programming: It is strongly recommended that you develop and test your Converter class and your TripSetter class independently.


5.1 Modifying the Converter Class
You should use the textual algorithm from Part a to add the toMiles() function to the Converter class.

There must not be a main() method in your Converter class.


5.2 Testing the Converter.toMiles() Function
You must test your implementation of Converter.toMiles() with the following values. (Note: The results in this table are rounded to two decimal places.)
Feet Miles
0 0.00
1000 0.19
1320 0.25
2173 0.41
2640 0.50
5280 1.00
10560 2.00
105600 20.00
2138958 405.11

To facilitate the process, you may use the following program:

You should read and understand this program before using it.


5.3 Regression Testing of the Converter Class
When you are done testing the Converter.toMiles() function, you should make sure you didn't break anything that was already working. This is a process that is known as regression testing. To that end, you should test Converter.toKPH() using all of the test cases you used earlier.


5.4 Developing the TripSetter Class
After completing all of the testing of the Converter class, you should use the textual algorithm from Part a to implement the TripSetter class.


5.5 Testing the TripSetter Class
You must test the trip-related functionality of the TripSetter class using the following values. (Note: The results in this table are rounded to two decimal places.)
Distance Duration mi/hr km/hr
200 1.00 0.04 0.06
5280 1.00 1.00 1.61
5280 2.00 0.50 0.80
316800 1.00 60.00 96.56
316800 0.75 80.00 128.75
316800 1.25 48.00 77.25
423198 1.47 54.52 87.75

You must use test the current speed functionality using the same test cases you used to test the SpeedPrinter class.

Obviously, you will need to execute the TripSetter program seven times (with seven different sets of command-line arguments).

6 Submitting Your Code: You must submit your code using the on-line Web-CAT server and then attest to your submission using Blackboard.

In order to reduce the burden on the Web-CAT server, you should test your code off-line before using Web-CAT. To facilitate that process, you should:

  1. Download junit.jar to your working folder/directory. (Note: Remember to right-click when downloading.)
  2. Download PA2TestSuite.jar to your working folder/directory. (Note: Remember to right-click when downloading.)
  3. Compile your Converter and TripSetter classes.
  4. Click (or double-click, depending on the operating system) on PA2TestSuite.jar to execute it. (Note: If the test suite does not execute it is probably because your operating system does not recognize executable .jar files. In this case, you can execute it from the command shell using the command java -jar PA2TestSuite.jar)
  5. Review the results of the tests (which will be presented in a new window).
  6. Close the results window.

If your code fails any of the tests, you will be given hints that should help you correct your mistakes.

7 Some Reminders about the Grading of Code: You should have read all of the course policies by now. However, just in case you've forgotten, there are several particularly important policies you should be aware of.

Your code must pass all of the tests. If not, you will receive a grade of 0.

Late submissions will not be accepted. If your code is submitted late, even one second late, you will receive a grade of 0.

It is not enough that your code works. You will be penalized (perhaps severely) for code that: does not satisfy the course style guide, is inelegant, contains duplicative sections, or is badly designed.

Going Further


Copyright 2013