Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider 371f6655 rédigé par Erwan BOUSSE's avatar Erwan BOUSSE
Parcourir les fichiers

Add missing "addTrain" operation

parent d2830534
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -81,6 +81,12 @@ public interface TicketReservationSystem {
*/
void addCity(City city);
/**
* Adds a new train in the system.
* @param train The train to add.
*/
void addTrain(Train train);
/**
* Creates and registers a new trip in the system.
* This new trip must take place *after* the last trip of the chosen train (based on the real arrival time).
......
......@@ -164,4 +164,10 @@ public class TicketReservationSystemImpl implements TicketReservationSystem {
public List<Trip> findOrderedTripsOfTrain(Train train) {
return trips.stream().sorted((t1, t2) -> t1.findRealArrivalTime().isBefore(t2.findRealDepartureTime()) ? -1 : 1).collect(Collectors.toList());
}
@Override
public void addTrain(Train train) {
this.trains.add(train);
}
}
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter