#32 AC done lab MC

開啟中
theuglyduck 請求將 1 次程式碼提交從 theuglyduck/ZCW-MetricConversions-BlueJ:master 合併至 master
共有 6 個檔案被更改,包括 131 行新增15 行删除
  1. 二進制
      ConversionTool.class
  2. 21
    0
      ConversionTool.ctxt
  3. 61
    9
      ConversionTool.java
  4. 二進制
      ConversionToolSpec.class
  5. 43
    0
      ConversionToolSpec.ctxt
  6. 6
    6
      package.bluej

二進制
ConversionTool.class 查看文件


+ 21
- 0
ConversionTool.ctxt 查看文件

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

+ 61
- 9
ConversionTool.java 查看文件

1
 public class ConversionTool {
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
+        float inch = centimeters * (float) 0.393701;
8
+        if (centimeters < 0){
9
+            return 0;
10
+        } else {
11
+            return inch;
12
+        }
5
 
13
 
6
-    public static float CentimetersToInches(float centimeters){}
14
+    }
7
 
15
 
8
-    public static float InchesToCentimeters(float inches){}
16
+    public static float InchesToCentimeters(float inches){
17
+        float centimeters = inches * (float) 2.54;
18
+        if (inches < 0) {
19
+            return 0;
20
+        } else {
21
+            return centimeters;
22
+        }
9
 
23
 
10
-    public static float FeetToMeters(float feet){}
24
+    }
11
 
25
 
12
-    public static float MetersToFeet(float meters){}
26
+    public static float FeetToMeters(float feet){
27
+        float meters = feet * (float) 0.304800164592;
28
+        if (meters < 0){
29
+            return 0;
30
+        }
31
+        return meters;
32
+    }
13
 
33
 
14
-    public static float CelsiusToFahrenheit(float celsius){}
34
+    public static float MetersToFeet(float meters){
35
+        float feet = meters * (float) 3.28084166666666599;
36
+        if (meters < 0) {
37
+            return 0;
38
+        } 
39
+        return feet;
40
+    }
15
 
41
 
16
-    public static float FahrenheitToCelsius(float fahrenheit){}
42
+    public static float CelsiusToFahrenheit(float celsius){
43
+        float fahrenheit =((celsius)* (float)1.8) + (float)32 ;
44
+        if (fahrenheit < 0 ){
45
+            return 0;
46
+        }
47
+        return fahrenheit; //this is the problem
48
+    }
17
 
49
 
18
-    public static float MphToKph(float mph){}
50
+    public static float FahrenheitToCelsius(float fahrenheit){
51
+        float celsius = (fahrenheit - 32)/(float)1.8;
52
+        if (fahrenheit < 0) {
53
+            return  0;
54
+        }
55
+        return celsius; //this is the problem too
56
+    }
19
 
57
 
20
-    public static float KphToMph(float kph){}
58
+    public static float MphToKph(float mph){
59
+        float kph = mph * (float) 1.60934;
60
+        if (mph < 0) {
61
+            return 0;
62
+        }
63
+        return kph;
64
+    }
65
+
66
+    public static float KphToMph(float kph){
67
+        float mph = kph *(float) 0.621371;
68
+        if (kph < 0){
69
+            return 0;
70
+        }
71
+        return mph;
72
+    }
21
 }
73
 }

二進制
ConversionToolSpec.class 查看文件


+ 43
- 0
ConversionToolSpec.ctxt 查看文件

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
- 6
package.bluej 查看文件

4
 dependency1.type=UsesDependency
4
 dependency1.type=UsesDependency
5
 editor.fx.0.height=722
5
 editor.fx.0.height=722
6
 editor.fx.0.width=800
6
 editor.fx.0.width=800
7
-editor.fx.0.x=320
8
-editor.fx.0.y=75
7
+editor.fx.0.x=425
8
+editor.fx.0.y=47
9
 objectbench.height=164
9
 objectbench.height=164
10
-objectbench.width=776
10
+objectbench.width=461
11
 package.divider.horizontal=0.6
11
 package.divider.horizontal=0.6
12
 package.divider.vertical=0.6845018450184502
12
 package.divider.vertical=0.6845018450184502
13
 package.editor.height=364
13
 package.editor.height=364
14
 package.editor.width=674
14
 package.editor.width=674
15
-package.editor.x=419
16
-package.editor.y=221
15
+package.editor.x=222
16
+package.editor.y=187
17
 package.frame.height=600
17
 package.frame.height=600
18
 package.frame.width=800
18
 package.frame.width=800
19
 package.numDependencies=1
19
 package.numDependencies=1
29
 target1.height=50
29
 target1.height=50
30
 target1.name=ConversionToolSpec
30
 target1.name=ConversionToolSpec
31
 target1.showInterface=false
31
 target1.showInterface=false
32
-target1.type=ClassTarget
32
+target1.type=UnitTestTargetJunit4
33
 target1.width=150
33
 target1.width=150
34
 target1.x=130
34
 target1.x=130
35
 target1.y=10
35
 target1.y=10