Skip to content

Commit 445922a

Browse files
committed
♻ Refactorisation Commune
1 parent 1c8e0b1 commit 445922a

File tree

4 files changed

+73
-30
lines changed

4 files changed

+73
-30
lines changed

src/main/java/fr/france/Commune.java

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
* @see Departement
1919
*
2020
* @author MathieuSoysal
21-
* @version 1.0.0
21+
* @author fabien-zoccola
22+
*
23+
* @version 1.1.0
2224
*/
2325
public class Commune {
2426
@CsvBindByPosition(position = 0)
@@ -58,21 +60,14 @@ public int getCodePostal() {
5860
}
5961

6062
/**
61-
* @return la latitude de la commune
62-
*/
63-
public double getLatitude() {
64-
return latitude;
65-
}
66-
67-
/**
68-
* @return la longitude de la commune
63+
* @return la localisation de la caumune
64+
*
65+
* @see Localisation
66+
*
67+
* @since 1.1.0
6968
*/
70-
public double getLongitude() {
71-
return longitude;
72-
}
73-
74-
public double[] getCoordonnees() {
75-
return new double[] {latitude, longitude};
69+
public Localisation getLocalisation() {
70+
return new Localisation(latitude, longitude);
7671
}
7772

7873
/**
@@ -142,7 +137,8 @@ public boolean equals(Object obj) {
142137
return false;
143138
if (nom == null) {
144139
return other.nom == null;
145-
} else return nom.equals(other.nom);
140+
} else
141+
return nom.equals(other.nom);
146142
}
147143

148144
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package fr.france;
2+
3+
/**
4+
* <b>Localisation est la classe représentant une localisation gps.</b>
5+
* <p>
6+
* Un objet Localisation est caractérisé par les informations suivantes :
7+
* <ul>
8+
* <li>Une latitude.</li>
9+
* <li>Une longitude.</li>
10+
* </ul>
11+
*
12+
* @author MathieuSoysal
13+
* @version 1.0.0
14+
*/
15+
public class Localisation {
16+
private final double latitude;
17+
private final double longitude;
18+
19+
public Localisation(double lat, double lon) {
20+
latitude = lat;
21+
longitude = lon;
22+
}
23+
24+
/**
25+
* @return la latitude de la localisation
26+
*/
27+
public double getLatitude() {
28+
return latitude;
29+
}
30+
31+
/**
32+
* @return la longitude de la localisation
33+
*/
34+
public double getLongitude() {
35+
return longitude;
36+
}
37+
}

src/test/java/fr/france/CommuneTest.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,10 @@ void test_getCodePostal() {
3939
}
4040

4141
@Test
42-
void test_getCoordonnees() {
43-
double[] coord = new double[] {43.6134409138d, 3.86851657896d};
44-
assertEquals(coord[0], Commune.getCoordonnees()[0]);
45-
assertEquals(coord[1], Commune.getCoordonnees()[1]);
46-
}
47-
48-
@Test
49-
void test_getLatitude() {
50-
assertEquals(43.6134409138d, Commune.getLatitude());
51-
}
52-
53-
@Test
54-
void test_getLongitude() {
55-
assertEquals(3.86851657896d, Commune.getLongitude());
42+
void test_getLocalisation() {
43+
Localisation localisation = new Localisation(43.6134409138d, 3.86851657896d);
44+
assertEquals(localisation.getLatitude(), Commune.getLocalisation().getLatitude());
45+
assertEquals(localisation.getLongitude(), Commune.getLocalisation().getLongitude());
5646
}
5747

5848
@Test
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package fr.france;
2+
3+
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
5+
import org.junit.jupiter.api.Test;
6+
7+
class LocalisationTest {
8+
9+
private Localisation localisation = new Localisation(43.6134409138d, 3.86851657896d);
10+
11+
@Test
12+
void test_getLatitude() {
13+
assertEquals(43.6134409138d, localisation.getLatitude());
14+
}
15+
16+
@Test
17+
void test_getLongitude() {
18+
assertEquals(3.86851657896d, localisation.getLongitude());
19+
}
20+
}

0 commit comments

Comments
 (0)