Shivam Patel 6 vuotta sitten
vanhempi
commit
1682c7f7f5
7 muutettua tiedostoa jossa 132 lisäystä ja 13 poistoa
  1. BIN
      ConversionTool.class
  2. 21
    0
      ConversionTool.ctxt
  3. 59
    10
      ConversionTool.java
  4. BIN
      ConversionToolSpec.class
  5. 43
    0
      ConversionToolSpec.ctxt
  6. 6
    0
      ConversionToolSpec.java
  7. 3
    3
      package.bluej

BIN
ConversionTool.class Näytä tiedosto


+ 21
- 0
ConversionTool.ctxt Näytä tiedosto

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

+ 59
- 10
ConversionTool.java Näytä tiedosto

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

BIN
ConversionToolSpec.class Näytä tiedosto


+ 43
- 0
ConversionToolSpec.ctxt Näytä tiedosto

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

+ 6
- 0
ConversionToolSpec.java Näytä tiedosto

@@ -19,6 +19,7 @@ public class ConversionToolSpec {
19 19
         assertEquals(0, inches, 0.0);
20 20
     }
21 21
 
22
+    
22 23
     @Test
23 24
     public void shouldConvertInchesToCentimeters() {
24 25
         float centimeters = ConversionTool.InchesToCentimeters(4f);
@@ -35,6 +36,7 @@ public class ConversionToolSpec {
35 36
         assertEquals(0, centimeters, 0.0);
36 37
     }
37 38
 
39
+    
38 40
     @Test
39 41
     public void shouldConvertFeetToMeters() {
40 42
         float meters = ConversionTool.FeetToMeters(5f);
@@ -51,6 +53,7 @@ public class ConversionToolSpec {
51 53
         assertEquals(0, meters, 0.0);
52 54
     }
53 55
 
56
+    
54 57
     @Test
55 58
     public void shouldConvertMetersToFeet() {
56 59
         float feet = ConversionTool.MetersToFeet(9f);
@@ -67,6 +70,7 @@ public class ConversionToolSpec {
67 70
         assertEquals(0, feet, 0.0);
68 71
     }
69 72
 
73
+    
70 74
     @Test
71 75
     public void shouldConvertFahrenheitToCelsius() {
72 76
         float celsius = ConversionTool.FahrenheitToCelsius(80);
@@ -78,6 +82,7 @@ public class ConversionToolSpec {
78 82
         assertEquals(80, fahrenheit, 0.01);
79 83
     }
80 84
 
85
+    
81 86
     @Test
82 87
     public void shouldConvertMphToKph(){
83 88
         float kph = ConversionTool.MphToKph(24f);
@@ -94,6 +99,7 @@ public class ConversionToolSpec {
94 99
         assertEquals(0, kph, 0.0);
95 100
     }
96 101
 
102
+    
97 103
     @Test
98 104
     public void shouldConvertKphToMph(){
99 105
         float mph = ConversionTool.KphToMph(6.44f);

+ 3
- 3
package.bluej Näytä tiedosto

@@ -4,8 +4,8 @@ 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=320
8
-editor.fx.0.y=75
7
+editor.fx.0.x=735
8
+editor.fx.0.y=238
9 9
 objectbench.height=164
10 10
 objectbench.width=776
11 11
 package.divider.horizontal=0.6
@@ -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