Ajout du lancement d'exception d'argument invalide si le ticket passé n'est pas pris en charge

This commit is contained in:
Feror 2025-01-23 12:19:20 +01:00
parent 45e760fcac
commit 20d1b4dd03

View file

@ -3,6 +3,10 @@ package org.example;
public class FeeCalculator { public class FeeCalculator {
public static double calculateFee(Visitor visitor, TicketType ticketType) { public static double calculateFee(Visitor visitor, TicketType ticketType) {
if (TicketType.HALF_DAY != ticketType && TicketType.FULL_DAY != ticketType) {
throw new IllegalArgumentException("Invalid ticket type");
}
double fee = visitor.calculateFee(ticketType); double fee = visitor.calculateFee(ticketType);
return fee; return fee;
} }