Bläddra i källkod

space-age: standardize starter implementation

Stuart Kent 9 år sedan
förälder
incheckning
a892c053f4

+ 13
- 12
exercises/space-age/src/example/java/SpaceAge.java Visa fil

1
 import java.math.BigDecimal;
1
 import java.math.BigDecimal;
2
 
2
 
3
-public class SpaceAge {
3
+class SpaceAge {
4
 
4
 
5
     private enum Planet {
5
     private enum Planet {
6
         EARTH(1.0),
6
         EARTH(1.0),
18
             this.relativeOrbitalPeriod = relativeOrbitalPeriod;
18
             this.relativeOrbitalPeriod = relativeOrbitalPeriod;
19
         }
19
         }
20
 
20
 
21
-        public double getRelativeOrbitalPeriod() {
21
+        private double getRelativeOrbitalPeriod() {
22
             return relativeOrbitalPeriod;
22
             return relativeOrbitalPeriod;
23
         }
23
         }
24
     }
24
     }
28
 
28
 
29
     private double seconds;
29
     private double seconds;
30
 
30
 
31
-    public SpaceAge(double seconds) {
31
+    SpaceAge(double seconds) {
32
         this.seconds = seconds;
32
         this.seconds = seconds;
33
     }
33
     }
34
 
34
 
35
-    public double getSeconds() {
35
+    double getSeconds() {
36
         return seconds;
36
         return seconds;
37
     }
37
     }
38
 
38
 
39
-    public double onEarth() {
39
+    double onEarth() {
40
         return calculateAge(Planet.EARTH);
40
         return calculateAge(Planet.EARTH);
41
     }
41
     }
42
 
42
 
43
-    public double onMercury() {
43
+    double onMercury() {
44
         return calculateAge(Planet.MERCURY);
44
         return calculateAge(Planet.MERCURY);
45
     }
45
     }
46
 
46
 
47
-    public double onVenus() {
47
+    double onVenus() {
48
         return calculateAge(Planet.VENUS);
48
         return calculateAge(Planet.VENUS);
49
     }
49
     }
50
 
50
 
51
-    public double onMars() {
51
+    double onMars() {
52
         return calculateAge(Planet.MARS);
52
         return calculateAge(Planet.MARS);
53
     }
53
     }
54
 
54
 
55
-    public double onJupiter() {
55
+    double onJupiter() {
56
         return calculateAge(Planet.JUPITER);
56
         return calculateAge(Planet.JUPITER);
57
     }
57
     }
58
 
58
 
59
-    public double onSaturn() {
59
+    double onSaturn() {
60
         return calculateAge(Planet.SATURN);
60
         return calculateAge(Planet.SATURN);
61
     }
61
     }
62
 
62
 
63
-    public double onUranus() {
63
+    double onUranus() {
64
         return calculateAge(Planet.URANUS);
64
         return calculateAge(Planet.URANUS);
65
     }
65
     }
66
 
66
 
67
-    public double onNeptune() {
67
+    double onNeptune() {
68
         return calculateAge(Planet.NEPTUNE);
68
         return calculateAge(Planet.NEPTUNE);
69
     }
69
     }
70
 
70
 
73
 
73
 
74
         return new BigDecimal(age).setScale(PRECISION, BigDecimal.ROUND_HALF_UP).doubleValue();
74
         return new BigDecimal(age).setScale(PRECISION, BigDecimal.ROUND_HALF_UP).doubleValue();
75
     }
75
     }
76
+
76
 }
77
 }

+ 0
- 0
exercises/space-age/src/main/java/.keep Visa fil


+ 43
- 0
exercises/space-age/src/main/java/SpaceAge.java Visa fil

1
+class SpaceAge {
2
+
3
+    SpaceAge(double seconds) {
4
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
5
+    }
6
+
7
+    double getSeconds() {
8
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
9
+    }
10
+
11
+    double onEarth() {
12
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
13
+    }
14
+
15
+    double onMercury() {
16
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
17
+    }
18
+
19
+    double onVenus() {
20
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
21
+    }
22
+
23
+    double onMars() {
24
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
25
+    }
26
+
27
+    double onJupiter() {
28
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
29
+    }
30
+
31
+    double onSaturn() {
32
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
33
+    }
34
+
35
+    double onUranus() {
36
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
37
+    }
38
+
39
+    double onNeptune() {
40
+        throw new UnsupportedOperationException("Delete this statement and write your own implementation.");
41
+    }
42
+
43
+}