-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStation.java
More file actions
184 lines (157 loc) · 5.95 KB
/
Copy pathStation.java
File metadata and controls
184 lines (157 loc) · 5.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
// --- Station.java ---
import java.util.Arrays;
import java.util.ArrayList;
/**
* La classe Station représente une station du réseau de transport.
* Elle contient un identifiant, un nom, une description des services,
* la liste des lignes desservies, et des coordonnées scindées (lat/long).
*/
public class Station {
// --- Attributs principaux ---
private int identifiant;
private String nom;
private String[] servicesDisponibles;
private String[] lignesDesservies;
private String[] modesTransport;
// --- Coordonnées latitude ---
private int degresLatitude;
private int minutesLatitude;
private double secondesLatitude;
private char directionLatitude; // 'N' ou 'S'
// --- Coordonnées longitude ---
private int degresLongitude;
private int minutesLongitude;
private double secondesLongitude;
private char directionLongitude; // 'E' ou 'W'
/**
* Constructeur de la classe Station.
* <p>
* Initialise une nouvelle instance de Station en spécifiant l'identifiant, le nom, la liste des services disponibles, les lignes desservies, les modes de transport et les coordonnées de la station.
* </p>
*
* @param identifiant L'identifiant numérique de la station.
* @param nom Le nom de la station.
* @param servicesDisponibles Les services disponibles à la station.
* @param lignesDesservies Les lignes desservies par la station.
* @param modesTransport Les modes de transport disponibles à la station.
*
* @param degLat Degrés de la latitude.
* @param minLat Minutes de la latitude.
* @param secLat Secondes de la latitude.
* @param dirLat Direction de la latitude ('N' ou 'S').
*
* @param degLong Degrés de la longitude.
* @param minLong Minutes de la longitude.
* @param secLong Secondes de la longitude.
* @param dirLong Direction de la longitude ('E' ou 'W').
*/
public Station(int identifiant,
String nom,
String[] servicesDisponibles,
int degLat,
int minLat,
double secLat,
char dirLat,
int degLong,
int minLong,
double secLong,
char dirLong) {
this.identifiant = identifiant;
this.nom = nom;
this.servicesDisponibles = servicesDisponibles;
this.degresLatitude = degLat;
this.minutesLatitude = minLat;
this.secondesLatitude = secLat;
this.directionLatitude = dirLat;
this.degresLongitude = degLong;
this.minutesLongitude = minLong;
this.secondesLongitude = secLong;
this.directionLongitude = dirLong;
}
// --- Getters ---
/** Retourne l'identifiant de la station. */
public int getIdentifiant() {
return identifiant;
}
/** Retourne le nom de la station. */
public String getNom() {
return nom;
}
/** Retourne les services disponibles sous forme de chaîne. */
public String getServicesDisponibles() {
return Arrays.toString(servicesDisponibles);
}
/** Retourne les lignes desservies sous forme de chaîne. */
public String getLignesDesservies() {
ArrayList<String> lignesList = new ArrayList<>();
for (Ligne ligne : Lignes.getListeLignes()) {
if (Arrays.asList(ligne.getListeStationsDesservies()).contains(nom)) {
lignesList.add(ligne.getNom());
}
}
lignesDesservies = lignesList.toArray(new String[0]);
return Arrays.toString(lignesDesservies);
}
/** Retourne les modes de transport disponibles sous forme de chaîne. */
public String getModesTransport() {
ArrayList<String> modesList = new ArrayList<>();
for (Ligne ligne : Lignes.getListeLignes()) {
if (Arrays.asList(ligne.getListeStationsDesservies()).contains(nom)) {
modesList.add(ligne.getModeTransport());
}
}
modesTransport = modesList.toArray(new String[0]);
return Arrays.toString(modesTransport);
}
public int getDegresLatitude() {
return degresLatitude;
}
public int getMinutesLatitude() {
return minutesLatitude;
}
public double getSecondesLatitude() {
return secondesLatitude;
}
public char getDirectionLatitude() {
return directionLatitude;
}
public int getDegresLongitude() {
return degresLongitude;
}
public int getMinutesLongitude() {
return minutesLongitude;
}
public double getSecondesLongitude() {
return secondesLongitude;
}
public char getDirectionLongitude() {
return directionLongitude;
}
/** Renvoie une représentation simple de la station. */
public String toString() {
return identifiant + ") " + nom;
}
/**
* Retourne une description détaillée de la station.
* <p>
* La description inclut le nom, les services disponibles et les coordonnées complètes.
* </p>
*
* @return une chaîne qui détataille ltaes infortamations de la station.
*/
public String informationsDetaillees() {
return "Nom : " + nom + "\n"
+ "Services disponibles : " + this.getServicesDisponibles() + "\n"
+ "Lignes desservies : " + this.getLignesDesservies() + "\n"
+ "Modes de transport : " + this.getModesTransport() + "\n"
+ "Coordonnées : "
+ degresLatitude + "° "
+ minutesLatitude + "' "
+ secondesLatitude + "\" "
+ directionLatitude + " , "
+ degresLongitude + "° "
+ minutesLongitude + "' "
+ secondesLongitude + "\" "
+ directionLongitude;
}
}