|
@ -0,0 +1,41 @@ |
|
|
|
|
|
package hs.fulda.de.ci.exam.project; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.Map; |
|
|
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
|
|
|
|
|
|
|
|
public class FrontDeskOfficer extends Person{ |
|
|
|
|
|
|
|
|
|
|
|
Map<String, Itinerary> itineraryList = new ConcurrentHashMap<String, Itinerary>(); |
|
|
|
|
|
|
|
|
|
|
|
public FrontDeskOfficer(String name, Address address, String email, String phone) { |
|
|
|
|
|
super(name, address, email, phone); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void createItinerary(Airport start_airport, Airport final_airport, Date date){ |
|
|
|
|
|
Itinerary itinerary = new Itinerary(start_airport, final_airport, date); |
|
|
|
|
|
validateItinerary(itinerary); |
|
|
|
|
|
checkIfItineraryAlreadyExist(itinerary); |
|
|
|
|
|
itineraryList.put(generateKey(itinerary), itinerary); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public Collection<Itinerary> getAllItineraries() { |
|
|
|
|
|
return itineraryList.values(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void checkIfItineraryAlreadyExist(Itinerary itinerary){ |
|
|
|
|
|
if(itineraryList.containsKey(generateKey(itinerary))){ |
|
|
|
|
|
throw new RuntimeException("Itinerary Already Exists"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private String generateKey(Itinerary itinerary) { |
|
|
|
|
|
return String.format("%s-%s", itinerary.getStart_airport(), itinerary.getFinal_airport()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void validateItinerary(Itinerary itinerary){ |
|
|
|
|
|
itinerary.validateStartAirport(); |
|
|
|
|
|
itinerary.validateFinalAirport(); |
|
|
|
|
|
} |
|
|
|
|
|
} |