Kaynağa Gözat

initial commit

Froilan Miranda 6 yıl önce
işleme
f07d6543a8
5 değiştirilmiş dosya ile 199 ekleme ve 0 silme
  1. BIN
      .DS_Store
  2. 21
    0
      ConversionTool.java
  3. 113
    0
      ConversionToolSpec.java
  4. 23
    0
      README.md
  5. 42
    0
      package.bluej

BIN
.DS_Store Dosyayı Görüntüle


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

@@ -0,0 +1,21 @@
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
+
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){}
17
+
18
+    public static float MphToKph(float mph){}
19
+
20
+    public static float KphToMph(float kph){}
21
+}

+ 113
- 0
ConversionToolSpec.java Dosyayı Görüntüle

@@ -0,0 +1,113 @@
1
+import static org.junit.Assert.assertEquals;
2
+import org.junit.Test;
3
+
4
+public class ConversionToolSpec {
5
+
6
+    @Test
7
+    public void shouldConvertCentimetersToInches() {
8
+        float inches = ConversionTool.CentimetersToInches(2f);
9
+        assertEquals(0.7874f, inches, 0.001);
10
+    }
11
+    @Test
12
+    public void shouldConvertZeroCentimetersToZeroInches() {
13
+        float inches = ConversionTool.CentimetersToInches(0);
14
+        assertEquals(0, inches, 0.0);
15
+    }
16
+    @Test
17
+    public void shouldConvertNegativeCentimetersToZeroInches() {
18
+        float inches = ConversionTool.CentimetersToInches(-5);
19
+        assertEquals(0, inches, 0.0);
20
+    }
21
+
22
+    @Test
23
+    public void shouldConvertInchesToCentimeters() {
24
+        float centimeters = ConversionTool.InchesToCentimeters(4f);
25
+        assertEquals(10.16f, centimeters, 0.001);
26
+    }
27
+    @Test
28
+    public void shouldConvertZeroInchesToZeroCentimeters() {
29
+        float centimeters = ConversionTool.InchesToCentimeters(0);
30
+        assertEquals(0, centimeters, 0.0);
31
+    }
32
+    @Test
33
+    public void shouldConvertNegativeInchesToZeroCentimeters() {
34
+        float centimeters = ConversionTool.InchesToCentimeters(-5);
35
+        assertEquals(0, centimeters, 0.0);
36
+    }
37
+
38
+    @Test
39
+    public void shouldConvertFeetToMeters() {
40
+        float meters = ConversionTool.FeetToMeters(5f);
41
+        assertEquals(1.524f, meters, 0.001);
42
+    }
43
+    @Test
44
+    public void shouldConvertZeroFeetToZeroMeters() {
45
+        float meters = ConversionTool.FeetToMeters(0);
46
+        assertEquals(0, meters, 0.0);
47
+    }
48
+    @Test
49
+    public void shouldConvertNegativeFeetToZeroMeters() {
50
+        float meters = ConversionTool.FeetToMeters(-10);
51
+        assertEquals(0, meters, 0.0);
52
+    }
53
+
54
+    @Test
55
+    public void shouldConvertMetersToFeet() {
56
+        float feet = ConversionTool.MetersToFeet(9f);
57
+        assertEquals(29.5276f, feet, 0.001);
58
+    }
59
+    @Test
60
+    public void shouldConvertZeroMetersToZeroFeet() {
61
+        float feet = ConversionTool.MetersToFeet(0);
62
+        assertEquals(0, feet, 0.0);
63
+    }
64
+    @Test
65
+    public void shouldConvertNegativeMetersToZeroFeet() {
66
+        float feet = ConversionTool.MetersToFeet(-10);
67
+        assertEquals(0, feet, 0.0);
68
+    }
69
+
70
+    @Test
71
+    public void shouldConvertFahrenheitToCelsius() {
72
+        float celsius = ConversionTool.FahrenheitToCelsius(80);
73
+        assertEquals(26.67, celsius, 0.01);
74
+    }
75
+    @Test
76
+    public void shouldConvertCelsiusToFahrenheit() {
77
+        float fahrenheit = ConversionTool.CelsiusToFahrenheit(26.67f);
78
+        assertEquals(80, fahrenheit, 0.01);
79
+    }
80
+
81
+    @Test
82
+    public void shouldConvertMphToKph(){
83
+        float kph = ConversionTool.MphToKph(24f);
84
+        assertEquals(38.62, kph, 0.01);
85
+    }
86
+    @Test
87
+    public void shouldConvertZeroMphToZeroKph(){
88
+        float kph = ConversionTool.MphToKph(0f);
89
+        assertEquals(0, kph, 0.0);
90
+    }
91
+    @Test
92
+    public void shouldConvertNegativeMphToZeroKph(){
93
+        float kph = ConversionTool.MphToKph(-50f);
94
+        assertEquals(0, kph, 0.0);
95
+    }
96
+
97
+    @Test
98
+    public void shouldConvertKphToMph(){
99
+        float mph = ConversionTool.KphToMph(6.44f);
100
+        assertEquals(4, mph, 0.01);
101
+    }
102
+    @Test
103
+    public void shouldConvertZeroKphToZeroMph(){
104
+        float mph = ConversionTool.KphToMph(0f);
105
+        assertEquals(0, mph, 0.0);
106
+    }
107
+    @Test
108
+    public void shouldConvertNegativeKphToZeroMph(){
109
+        float mph = ConversionTool.KphToMph(-50f);
110
+        assertEquals(0, mph, 0.0);
111
+    }
112
+
113
+}

+ 23
- 0
README.md Dosyayı Görüntüle

@@ -0,0 +1,23 @@
1
+## Conversion Tool
2
+
3
+This tool converts different units of measure. Methods have been stubbed out to convert the following:
4
+
5
+- Centimeters <-> Inches
6
+- Feet <-> Meters
7
+- Celcius <-> Fahrenheit
8
+- MPH <-> KPH
9
+
10
+This tool should only convert positive numbers. Any negative numbers that are passed should return 0 (This excludes temperature conversions, negative values can be converted) 
11
+
12
+Complete the implementation so that all test pass
13
+
14
+---
15
+
16
+This lab covers the following competencies:
17
+
18
+- Variable instaniation
19
+- Constants
20
+- Order of operations
21
+- Conditionals
22
+- Block scope
23
+- Floating point arithmatic

+ 42
- 0
package.bluej Dosyayı Görüntüle

@@ -0,0 +1,42 @@
1
+#BlueJ package file
2
+dependency1.from=ConversionToolSpec
3
+dependency1.to=ConversionTool
4
+dependency1.type=UsesDependency
5
+editor.fx.0.height=722
6
+editor.fx.0.width=800
7
+editor.fx.0.x=320
8
+editor.fx.0.y=75
9
+objectbench.height=164
10
+objectbench.width=776
11
+package.divider.horizontal=0.6
12
+package.divider.vertical=0.6845018450184502
13
+package.editor.height=364
14
+package.editor.width=674
15
+package.editor.x=419
16
+package.editor.y=221
17
+package.frame.height=600
18
+package.frame.width=800
19
+package.numDependencies=1
20
+package.numTargets=2
21
+package.showExtends=true
22
+package.showUses=true
23
+project.charset=UTF-8
24
+readme.height=58
25
+readme.name=@README
26
+readme.width=47
27
+readme.x=10
28
+readme.y=10
29
+target1.height=50
30
+target1.name=ConversionToolSpec
31
+target1.showInterface=false
32
+target1.type=ClassTarget
33
+target1.width=150
34
+target1.x=130
35
+target1.y=10
36
+target2.height=50
37
+target2.name=ConversionTool
38
+target2.showInterface=false
39
+target2.type=ClassTarget
40
+target2.width=120
41
+target2.x=250
42
+target2.y=110