Browse Source

completed lab

Eric Foster 6 years ago
parent
commit
4668dd26d0
6 changed files with 128 additions and 19 deletions
  1. BIN
      ConversionTool.class
  2. 19
    0
      ConversionTool.ctxt
  3. 58
    11
      ConversionTool.java
  4. BIN
      ConversionToolSpec.class
  5. 43
    0
      ConversionToolSpec.ctxt
  6. 8
    8
      package.bluej

BIN
ConversionTool.class View File


+ 19
- 0
ConversionTool.ctxt View File

@@ -0,0 +1,19 @@
1
+#BlueJ class context
2
+comment0.target=ConversionTool
3
+comment1.params=centimeters
4
+comment1.target=float\ CentimetersToInches(float)
5
+comment2.params=inches
6
+comment2.target=float\ InchesToCentimeters(float)
7
+comment3.params=feet
8
+comment3.target=float\ FeetToMeters(float)
9
+comment4.params=meters
10
+comment4.target=float\ MetersToFeet(float)
11
+comment5.params=celsius
12
+comment5.target=float\ CelsiusToFahrenheit(float)
13
+comment6.params=fahrenheit
14
+comment6.target=float\ FahrenheitToCelsius(float)
15
+comment7.params=mph
16
+comment7.target=float\ MphToKph(float)
17
+comment8.params=kph
18
+comment8.target=float\ KphToMph(float)
19
+numComments=9

+ 58
- 11
ConversionTool.java View File

@@ -1,21 +1,68 @@
1 1
 public class ConversionTool {
2
+    public static final float IN_2_CM = 2.54f;
3
+    public static final float CM_2_IN = 1 / IN_2_CM;
4
+    public static final float FT_2_IN = 12f;
5
+    public static final float IN_2_FT = 1 / FT_2_IN;
6
+    public static final float M_2_CM = 100f;
7
+    public static final float CM_2_M = 1 / M_2_CM;
8
+    public static final float KM_2_CM = 100000f;
9
+    public static final float CM_2_KM = 1 / KM_2_CM;
10
+    public static final float MI_2_IN = 63360f;
11
+    public static final float IN_2_MI = 1 / MI_2_IN;
2 12
 
13
+    public static float CentimetersToInches(float centimeters){
14
+        float inches = 0;
15
+        if (centimeters > 0){
16
+            inches = centimeters * CM_2_IN;
17
+        }
18
+        return inches;
19
+    }
3 20
 
4
-    public static void main(String[] args){}
21
+    public static float InchesToCentimeters(float inches){
22
+        float centimeters = 0;
23
+        if (inches > 0){
24
+            centimeters = inches * IN_2_CM;
25
+        } 
26
+        return centimeters;
27
+    }
5 28
 
6
-    public static float CentimetersToInches(float centimeters){}
29
+    public static float FeetToMeters(float feet){
30
+        float meters = 0;
31
+        if (feet > 0){
32
+            meters = feet * FT_2_IN * IN_2_CM * CM_2_M;
33
+        }
34
+        return meters;
35
+    }
7 36
 
8
-    public static float InchesToCentimeters(float inches){}
37
+    public static float MetersToFeet(float meters){
38
+        float feet = 0;
39
+        if (meters > 0){
40
+            feet = meters * M_2_CM * CM_2_IN * IN_2_FT;
41
+        }
42
+        return feet;
43
+    }
9 44
 
10
-    public static float FeetToMeters(float feet){}
45
+    public static float CelsiusToFahrenheit(float celsius){
46
+        return celsius * (9f/5f) + 32f;
47
+    }
11 48
 
12
-    public static float MetersToFeet(float meters){}
49
+    public static float FahrenheitToCelsius(float fahrenheit){
50
+        return (fahrenheit - 32f) * (5f/9f);
51
+    }
13 52
 
14
-    public static float CelsiusToFahrenheit(float celsius){}
53
+    public static float MphToKph(float mph){
54
+        float kph = 0;
55
+        if (mph > 0){
56
+            kph = mph * MI_2_IN * IN_2_CM * CM_2_KM;
57
+        }
58
+        return kph;
59
+    }
15 60
 
16
-    public static float FahrenheitToCelsius(float fahrenheit){}
17
-
18
-    public static float MphToKph(float mph){}
19
-
20
-    public static float KphToMph(float kph){}
61
+    public static float KphToMph(float kph){
62
+        float mph = 0;
63
+        if (kph > 0){
64
+            mph = kph * KM_2_CM * CM_2_IN * IN_2_MI;
65
+        }
66
+        return mph;
67
+    }
21 68
 }

BIN
ConversionToolSpec.class View File


+ 43
- 0
ConversionToolSpec.ctxt View File

@@ -0,0 +1,43 @@
1
+#BlueJ class context
2
+comment0.target=ConversionToolSpec
3
+comment1.params=
4
+comment1.target=void\ shouldConvertCentimetersToInches()
5
+comment10.params=
6
+comment10.target=void\ shouldConvertMetersToFeet()
7
+comment11.params=
8
+comment11.target=void\ shouldConvertZeroMetersToZeroFeet()
9
+comment12.params=
10
+comment12.target=void\ shouldConvertNegativeMetersToZeroFeet()
11
+comment13.params=
12
+comment13.target=void\ shouldConvertFahrenheitToCelsius()
13
+comment14.params=
14
+comment14.target=void\ shouldConvertCelsiusToFahrenheit()
15
+comment15.params=
16
+comment15.target=void\ shouldConvertMphToKph()
17
+comment16.params=
18
+comment16.target=void\ shouldConvertZeroMphToZeroKph()
19
+comment17.params=
20
+comment17.target=void\ shouldConvertNegativeMphToZeroKph()
21
+comment18.params=
22
+comment18.target=void\ shouldConvertKphToMph()
23
+comment19.params=
24
+comment19.target=void\ shouldConvertZeroKphToZeroMph()
25
+comment2.params=
26
+comment2.target=void\ shouldConvertZeroCentimetersToZeroInches()
27
+comment20.params=
28
+comment20.target=void\ shouldConvertNegativeKphToZeroMph()
29
+comment3.params=
30
+comment3.target=void\ shouldConvertNegativeCentimetersToZeroInches()
31
+comment4.params=
32
+comment4.target=void\ shouldConvertInchesToCentimeters()
33
+comment5.params=
34
+comment5.target=void\ shouldConvertZeroInchesToZeroCentimeters()
35
+comment6.params=
36
+comment6.target=void\ shouldConvertNegativeInchesToZeroCentimeters()
37
+comment7.params=
38
+comment7.target=void\ shouldConvertFeetToMeters()
39
+comment8.params=
40
+comment8.target=void\ shouldConvertZeroFeetToZeroMeters()
41
+comment9.params=
42
+comment9.target=void\ shouldConvertNegativeFeetToZeroMeters()
43
+numComments=21

+ 8
- 8
package.bluej View File

@@ -2,18 +2,18 @@
2 2
 dependency1.from=ConversionToolSpec
3 3
 dependency1.to=ConversionTool
4 4
 dependency1.type=UsesDependency
5
-editor.fx.0.height=722
6
-editor.fx.0.width=800
7
-editor.fx.0.x=320
8
-editor.fx.0.y=75
5
+editor.fx.0.height=0
6
+editor.fx.0.width=0
7
+editor.fx.0.x=0
8
+editor.fx.0.y=0
9 9
 objectbench.height=164
10
-objectbench.width=776
10
+objectbench.width=461
11 11
 package.divider.horizontal=0.6
12 12
 package.divider.vertical=0.6845018450184502
13 13
 package.editor.height=364
14 14
 package.editor.width=674
15
-package.editor.x=419
16
-package.editor.y=221
15
+package.editor.x=10
16
+package.editor.y=23
17 17
 package.frame.height=600
18 18
 package.frame.width=800
19 19
 package.numDependencies=1
@@ -29,7 +29,7 @@ readme.y=10
29 29
 target1.height=50
30 30
 target1.name=ConversionToolSpec
31 31
 target1.showInterface=false
32
-target1.type=ClassTarget
32
+target1.type=UnitTestTargetJunit4
33 33
 target1.width=150
34 34
 target1.x=130
35 35
 target1.y=10