Clement Ojie hace 6 años
padre
commit
3b0372edbd
Se han modificado 4 ficheros con 80 adiciones y 13 borrados
  1. BIN
      ConversionTool.class
  2. 35
    11
      ConversionTool.java
  3. 43
    0
      ConversionToolSpec.ctxt
  4. 2
    2
      package.bluej

BIN
ConversionTool.class Ver fichero


+ 35
- 11
ConversionTool.java Ver fichero

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

+ 43
- 0
ConversionToolSpec.ctxt Ver fichero

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

+ 2
- 2
package.bluej Ver fichero

@@ -4,7 +4,7 @@ dependency1.to=ConversionTool
4 4
 dependency1.type=UsesDependency
5 5
 editor.fx.0.height=722
6 6
 editor.fx.0.width=800
7
-editor.fx.0.x=480
7
+editor.fx.0.x=521
8 8
 editor.fx.0.y=23
9 9
 objectbench.height=165
10 10
 objectbench.width=776
@@ -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