Parcourir la source

Moved Gigasecond solution code from main file to example file (closes #29)

Piet van Dongen il y a 11 ans
Parent
révision
d7bb537471

+ 13
- 0
gigasecond/example.java Voir le fichier

@@ -1,3 +1,16 @@
1 1
 public class Gigasecond {
2 2
 
3
+    private LocalDateTime birthDateTime;
4
+
5
+    public Gigasecond(LocalDateTime birthDateTime) {
6
+        this.birthDateTime = birthDateTime;
7
+    }
8
+
9
+    public Gigasecond(LocalDate birthDate) {
10
+        this.birthDateTime = birthDate.atTime(0, 0);
11
+    }
12
+
13
+    public LocalDateTime getDate() {
14
+        return birthDateTime.plusSeconds(1000000000);
15
+    }
3 16
 }

+ 0
- 17
gigasecond/src/main/java/Gigasecond.java Voir le fichier

@@ -1,19 +1,2 @@
1
-import java.time.LocalDate;
2
-import java.time.LocalDateTime;
3
-
4 1
 public class Gigasecond {
5
-
6
-    private LocalDateTime birthDateTime;
7
-
8
-    public Gigasecond(LocalDateTime birthDateTime) {
9
-        this.birthDateTime = birthDateTime;
10
-    }
11
-
12
-    public Gigasecond(LocalDate birthDate) {
13
-        this.birthDateTime = birthDate.atTime(0, 0);
14
-    }
15
-
16
-    public LocalDateTime Date() {
17
-        return birthDateTime.plusSeconds(1000000000);
18
-    }
19 2
 }

+ 5
- 5
gigasecond/src/test/java/GigasecondTest.java Voir le fichier

@@ -12,34 +12,34 @@ public class GigasecondTest {
12 12
     public void modernTime() {
13 13
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(2011, Month.APRIL, 25));
14 14
 
15
-        assertEquals(gigaSecond.Date(), LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40));
15
+        assertEquals(gigaSecond.getDate(), LocalDateTime.of(2043, Month.JANUARY, 1, 1, 46, 40));
16 16
     }
17 17
 
18 18
     @Test
19 19
     public void afterEpochTime() {
20 20
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1977, Month.JUNE, 13));
21 21
 
22
-        assertEquals(gigaSecond.Date(), LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40));
22
+        assertEquals(gigaSecond.getDate(), LocalDateTime.of(2009, Month.FEBRUARY, 19, 1, 46, 40));
23 23
     }
24 24
 
25 25
     @Test
26 26
     public void beforeEpochTime() {
27 27
         Gigasecond gigaSecond = new Gigasecond(LocalDate.of(1959, Month.JULY, 19));
28 28
 
29
-        assertEquals(gigaSecond.Date(), LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40));
29
+        assertEquals(gigaSecond.getDate(), LocalDateTime.of(1991, Month.MARCH, 27, 1, 46, 40));
30 30
     }
31 31
 
32 32
     @Test
33 33
     public void withFullTimeSpecified() {
34 34
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 22, 0, 0));
35 35
 
36
-        assertEquals(gigaSecond.Date(), LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40));
36
+        assertEquals(gigaSecond.getDate(), LocalDateTime.of(2046, Month.OCTOBER, 2, 23, 46, 40));
37 37
     }
38 38
 
39 39
     @Test
40 40
     public void withFullTimeSpecifiedAndDayRollover() {
41 41
         Gigasecond gigaSecond = new Gigasecond(LocalDateTime.of(2015, Month.JANUARY, 24, 23, 59, 59));
42 42
 
43
-        assertEquals(gigaSecond.Date(), LocalDateTime.of(2046, Month.OCTOBER, 3, 1, 46, 39));
43
+        assertEquals(gigaSecond.getDate(), LocalDateTime.of(2046, Month.OCTOBER, 3, 1, 46, 39));
44 44
     }
45 45
 }