#38 dmjpub

Açık
dmjpub master içindeki dmjpub/ZCW-MetricConversions-BlueJ:master işlemelerini 1 ile birleştirmek istiyor

BIN
ConversionTool.class Dosyayı Görüntüle


+ 21
- 0
ConversionTool.ctxt Dosyayı Görüntüle

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

+ 66
- 15
ConversionTool.java Dosyayı Görüntüle

@@ -1,21 +1,72 @@
1 1
 public class ConversionTool {
2
-
3
-
2
+    public static final float CM_CONVERT = 0.3937008f;
3
+    public static final float IN_CONVERT = 2.54f;
4
+    public static final float FT_CONVERT = 3.28f;
5
+    public static final float M_CONVERT = 0.3048f;
6
+    public static final float CELSIUS_CONVERT = 1.8f;
7
+    public static final float CELSIUS_CSTNT2 = 32.0f;
8
+    public static final float FAHRENHT_CONVERT = 32.0f;
9
+    public static final float FAHRENHT_CSTNT2 = 5.0f;
10
+    public static final float FAHRENHT_CSTNT3 = 9.0f;
11
+    public static final float MPH_CONVERT = 1.6093440f;
12
+    public static final float KPH_CONVERT = 0.6214f;
13
+    
14
+    public static float cmToInches;
15
+    public static float inchesToCm;
16
+    public static float ftToMeters;
17
+    public static float metersToFt;
18
+    public static float mphToKph;
19
+    public static float kphToMph;
20
+    
4 21
     public static void main(String[] args){}
22
+    
23
+    public static float CentimetersToInches(float centimeters){
24
+        cmToInches = centimeters * CM_CONVERT;
25
+        if(cmToInches < 0) {return 0f;}
26
+        else
27
+        return cmToInches;
28
+    }
5 29
 
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){}
30
+    public static float InchesToCentimeters(float inches){
31
+        inchesToCm = inches * IN_CONVERT;
32
+        if(inchesToCm < 0) {return 0f;}
33
+        else
34
+        return inchesToCm;
35
+    }
17 36
 
18
-    public static float MphToKph(float mph){}
37
+    public static float FeetToMeters(float feet){
38
+        ftToMeters = feet / FT_CONVERT;
39
+        if(ftToMeters < 0) {return 0f;}
40
+        else
41
+        return ftToMeters;
42
+    }
43
+    
44
+    public static float MetersToFeet(float meters){
45
+        metersToFt = meters / M_CONVERT;
46
+        if(metersToFt < 0) {return 0f;}
47
+        else
48
+        return metersToFt;
49
+    }
50
+    
51
+    public static float CelsiusToFahrenheit(float celsius){
52
+        return (CELSIUS_CONVERT * celsius) + CELSIUS_CSTNT2;
53
+    }
54
+    
55
+    public static float FahrenheitToCelsius(float fahrenheit){
56
+        return ((fahrenheit - FAHRENHT_CONVERT) * FAHRENHT_CSTNT2) / FAHRENHT_CSTNT3;
57
+    }
19 58
 
20
-    public static float KphToMph(float kph){}
59
+    public static float MphToKph(float mph){
60
+        mphToKph = mph * MPH_CONVERT;
61
+        if(mphToKph < 0) {return 0f;}
62
+        else        
63
+        return mphToKph;
64
+    }
65
+    
66
+    public static float KphToMph(float kph){
67
+        kphToMph = kph * KPH_CONVERT;
68
+        if(kphToMph < 0) {return 0f;}
69
+        else        
70
+        return kphToMph;
71
+    }
21 72
 }

BIN
ConversionToolSpec.class Dosyayı Görüntüle


+ 43
- 0
ConversionToolSpec.ctxt Dosyayı Görüntüle

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