John Kim преди 6 години
родител
ревизия
c86e0b0a60
променени са 6 файла, в които са добавени 120 реда и са изтрити 21 реда
  1. BIN
      ConversionTool.class
  2. 23
    0
      ConversionTool.ctxt
  3. 49
    16
      ConversionTool.java
  4. BIN
      ConversionToolSpec.class
  5. 43
    0
      ConversionToolSpec.ctxt
  6. 5
    5
      package.bluej

BIN
ConversionTool.class Целия файл


+ 23
- 0
ConversionTool.ctxt Целия файл

@@ -0,0 +1,23 @@
1
+#BlueJ class context
2
+comment0.target=ConversionTool
3
+comment1.params=args
4
+comment1.target=void\ main(java.lang.String[])
5
+comment10.params=value
6
+comment10.target=boolean\ checkNegative(float)
7
+comment2.params=centimeters
8
+comment2.target=float\ CentimetersToInches(float)
9
+comment3.params=inches
10
+comment3.target=float\ InchesToCentimeters(float)
11
+comment4.params=feet
12
+comment4.target=float\ FeetToMeters(float)
13
+comment5.params=meters
14
+comment5.target=float\ MetersToFeet(float)
15
+comment6.params=celsius
16
+comment6.target=float\ CelsiusToFahrenheit(float)
17
+comment7.params=fahrenheit
18
+comment7.target=float\ FahrenheitToCelsius(float)
19
+comment8.params=mph
20
+comment8.target=float\ MphToKph(float)
21
+comment9.params=kph
22
+comment9.target=float\ KphToMph(float)
23
+numComments=11

+ 49
- 16
ConversionTool.java Целия файл

@@ -1,21 +1,54 @@
1 1
 public class ConversionTool {
2
-
2
+    private static final float CM_PER_INCH = 2.54f;
3
+    private static final float FT_PER_M = 3.28084f;
4
+    private static final float KM_PER_MILE = 1.60934f;
3 5
 
4 6
     public static void main(String[] args){}
5 7
 
6
-    public static float CentimetersToInches(float centimeters){}
7
-
8
-    public static float InchesToCentimeters(float inches){}
9
-
10
-    public static float FeetToMeters(float feet){}
11
-
12
-    public static float MetersToFeet(float meters){}
13
-
14
-    public static float CelsiusToFahrenheit(float celsius){}
15
-
16
-    public static float FahrenheitToCelsius(float fahrenheit){}
17
-
18
-    public static float MphToKph(float mph){}
19
-
20
-    public static float KphToMph(float kph){}
8
+    public static float CentimetersToInches(float centimeters){
9
+        if (checkNegative(centimeters)) return 0f;
10
+        return centimeters / CM_PER_INCH;
11
+    }
12
+
13
+    public static float InchesToCentimeters(float inches){
14
+        if (checkNegative(inches)) return 0f;
15
+        return inches * CM_PER_INCH;
16
+    }
17
+
18
+    public static float FeetToMeters(float feet){
19
+        if (checkNegative(feet)) return 0f;
20
+        return feet / FT_PER_M;
21
+    }
22
+
23
+    public static float MetersToFeet(float meters){
24
+        if (checkNegative(meters)) return 0f;
25
+        return meters * FT_PER_M;
26
+    }
27
+
28
+    public static float CelsiusToFahrenheit(float celsius){
29
+        if (checkNegative(celsius)) return 0f;
30
+        return celsius * 1.8f + 32.0f;
31
+    }
32
+
33
+    public static float FahrenheitToCelsius(float fahrenheit){
34
+        if (checkNegative(fahrenheit)) return 0f;
35
+        return (fahrenheit - 32) / 1.8f;
36
+    }
37
+
38
+    public static float MphToKph(float mph){
39
+        if (checkNegative(mph)) return 0f;
40
+        return mph * KM_PER_MILE;
41
+    }
42
+
43
+    public static float KphToMph(float kph){
44
+        if (checkNegative(kph)) return 0f;
45
+        return kph / KM_PER_MILE;
46
+    }
47
+    
48
+    private static boolean checkNegative(float value) {
49
+        if (value < 0) {
50
+            return true;
51
+        }
52
+        return false;
53
+    }
21 54
 }

BIN
ConversionToolSpec.class Целия файл


+ 43
- 0
ConversionToolSpec.ctxt Целия файл

@@ -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

+ 5
- 5
package.bluej Целия файл

@@ -2,10 +2,10 @@
2 2
 dependency1.from=ConversionToolSpec
3 3
 dependency1.to=ConversionTool
4 4
 dependency1.type=UsesDependency
5
-editor.fx.0.height=722
5
+editor.fx.0.height=709
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=320
8
-editor.fx.0.y=75
7
+editor.fx.0.x=453
8
+editor.fx.0.y=26
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6
@@ -13,7 +13,7 @@ package.divider.vertical=0.6845018450184502
13 13
 package.editor.height=364
14 14
 package.editor.width=674
15 15
 package.editor.x=419
16
-package.editor.y=221
16
+package.editor.y=132
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