Nantes Université

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

Finished first version of the API

parent b95713e4
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
package fr.univnantes;
/**
* Thrown when something wrong happens during a ticket reservation.
*/
public class ReservationException extends Exception {
}
package fr.univnantes;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.util.List;
......@@ -106,6 +107,8 @@ public interface TicketReservationSystem {
* - The train must not be already in another trip at the same time as the new trip.
* - The last destination of the train must be in the same city as the origin of the new trip.
* - The last arrival of the train must be at least 10 minutes from the departure of the new trip.
* - The arrival must come after the departure.
* - The origin must be different from the destination.
* @return The created registered trip.
* @throws TripException If one of the above constraints was not satisfied.
*/
......@@ -116,5 +119,21 @@ public interface TicketReservationSystem {
* @param trip The trip to cancel.
*/
void cancelTrip(Trip trip);
/**
* Adds a departure delay to a trip.
* Also automatically adds an arrival delay of the same amount.
* @param delay The amount of delay to add.
*/
void addDepartureDelay(Trip trip, Duration delay);
/**
* Adds an arrival delay to a trip.
* If needed, this automatically also adds delays to the next trip of the train, so that the next train
* departure remains at least 10 minutes from the arrival time of the delayed trip.
* @param delay The amount of delay to add.
*/
void addArrivalDelay(Trip trip, Duration delay);
}
package fr.univnantes;
/**
* Represents a train available in the rail system.
*/
public interface Train {
/**
* Retrieves the name of the train.
* @return The name of the train.
*/
String getName();
/**
* Retrieves the maximum amount of passengers that the train can contain.
* @return the maximum amount of passengers that the train can contain.
*/
int getMaxPassengers();
}
......@@ -4,23 +4,98 @@ import java.time.Duration;
import java.time.Instant;
import java.util.List;
/**
* Represents a trip between two cities, using a specific train and at a specific time.
*/
public interface Trip {
/**
* Retrieves the origin city of the trip.
* @return the origin city of the trip.
*/
City getOrigin();
/**
* Retrieves the destination city of the trip.
* @return the destination city of the trip.
*/
City getDestination();
/**
* Retrieves the train used for the trip.
* @return the train used for the trip.
*/
Train getTrain();
Duration getDuration();
/**
* Finds the duration of the trip.
* @return The duration of the trip (ie. the duration between departure and arrival).
*/
Duration findDuration();
/**
* Retrieves whether the trip was cancelled or not.
* @return true if the trip was cancelled, false otherwise.
*/
boolean isCancelled();
/**
* Retrieves whether the trip was delayed or not.
* @return true if the trip was delayed (ie. if the amount of delay it above zero), false otherwise.
*/
boolean isDelayed();
/**
* Cancels the trip.
* This also automatically cancels all tickets for this trip.
*/
void cancel();
/**
* Get the initially planned departure time.
* @return the initially planned departure time.
*/
Instant getPlannedDepartureTime();
/**
* Get the initially planned arrival time.
* @return the initially planned arrival time.
*/
Instant getPlannedArrivalTime();
Instant getRealDepartureTime();
Instant getRealArrivalTime();
void addDepartureDelay(Duration delay);
void addArrivalDelay(Duration delay);
void getDepartureDelay(Duration delay);
void getArrivalDelay(Duration delay);
/**
* Finds the real departure time, considering delays.
* @return the real departure time, considering delays.
*/
Instant findRealDepartureTime();
/**
* Finds the real arrival time, considering delays.
* @return the real arrival time, considering delays.
*/
Instant findRealArrivalTime();
/**
* Retrieves the departure delay for this trip.
* @return the departure delay.
*/
Duration getDepartureDelay();
/**
* Retrieves the arrival delay for this trip.
* @return the arrival delay.
*/
Duration getArrivalDelay();
/**
* Retrieves the list of all (non-cancelled) booked tickets for this trip.
* @return the list of all (non-cancelled) booked tickets for this trip.
*/
List<Ticket> getBookedTickets();
/**
* Retrieves the list of all cancelled tickets for this trip.
* @return the list of all cancelled tickets for this trip.
*/
List<Ticket> getCancelledTickets();
}
package fr.univnantes;
/**
* Thrown when something wrong happens during a trip creation.
*/
public class TripException extends Exception {
}
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