Jamez-s пре 6 година
родитељ
комит
265cec685f
7 измењених фајлова са 144 додато и 17 уклоњено
  1. BIN
      ConversionTool.class
  2. 21
    0
      ConversionTool.ctxt
  3. 79
    17
      ConversionTool.java
  4. BIN
      ConversionToolSpec.class
  5. 43
    0
      ConversionToolSpec.ctxt
  6. 1
    0
      ConversionToolSpec.java
  7. 0
    0
      README.TXT

BIN
ConversionTool.class Прегледај датотеку


+ 21
- 0
ConversionTool.ctxt Прегледај датотеку

@@ -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=fahrenheit
14
+comment6.target=float\ FahrenheitToCelsius(float)
15
+comment7.params=celsius
16
+comment7.target=float\ CelsiusToFahrenheit(float)
17
+comment8.params=mph
18
+comment8.target=float\ MphToKph(float)
19
+comment9.params=kph
20
+comment9.target=float\ KphToMph(float)
21
+numComments=10

+ 79
- 17
ConversionTool.java Прегледај датотеку

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

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

+ 1
- 0
ConversionToolSpec.java Прегледај датотеку

@@ -1,6 +1,7 @@
1 1
 import static org.junit.Assert.assertEquals;
2 2
 import org.junit.Test;
3 3
 
4
+
4 5
 public class ConversionToolSpec {
5 6
 
6 7
     @Test