In some situations, this system will be given the current speed in mi/hr and the speed limit in km/hr. In other situations, this system will only be given the current speed in mi/hr and will use the default speed limit of 40.0 km/hr. In both situations, it will convert the speed to km/hr, compare it to the speed limit, and modify the display accordingly. If the user-supplied speed limit is less than the smallest allowable speed limit (of 20.0 km/hr), the smallest allowable speed limit is used instead.
a. An algorithm for processing the command line arguments. (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 algorithm for processing the speed and speed limit. (Note: You may only attempt this part of the assignment once. Hence, it is only required that you attempt this part before starting the next part. However, if you do not earn a grade of 100% on this part you should make sure you understand all of the correct answers before starting the next part.)
c. A Java main class that is: given either 1 or 2 command-line strings containing the real-valued speed in mi/hr and an optional real-valued speed limit in km/hr, converts the strings as appropriate; performs the necessary calculations; and displays the results.
pa4
) that
will hold all of the files for this assignment.
Next, you should copy your Converter.class
and the
provided Text.class
and Dashboard.class
to the directory you just created.
getLength()
function in the Array
class
that is passed an array and returns an int
containing
the number of elements in that array.
To use this function in a class of yours, you must include the line:
import java.lang.reflect.*;
at the top of the source file for your class. (This is because the class
that contains the getLength()
function is neither in
your working directory nor in the directory where most built-in
Java classes are kept.)
DetailedSpeedSetter
class using the following values.
Speed (mi/hr) | Speed Limit (km/hr) | Speeding? |
0.0 | 0.0 | false |
24.8 | 40.0 | false |
24.9 | 40.0 | true |
25.0 | 40.3 | false |
40.0 | 60.0 | true |
40.0 | 64.37 | true |
40.0 | 65.0 | false |
100.0 | 160.0 | true |
100.0 | 160.9344 | true |
100.0 | 161.1 | false |
10.0 | 5.0 | false |
19.0 | 10.0 | true |
0.0 | false | |
24.8 | false | |
24.9 | true | |
40.0 | true |
Obviously, you will need to execute the
DetailedTripSetter
program fifteen times (with
fifteen different sets of command-line arguments).
You should probably create a script/batch file for this purpose
(that you can run from the command line).
In addition, you should test your code using the
PA4TestSuite.jar
(in the
same way you used PA3TestSuite.jar
for the previous
assignment). Before doing so, you will need to copy
junit.jar
to your working directory for this
assignment.
Copyright 2013