package education.jtrainer.tutorial.junit; public class ReservationService { public CarFactory carFactory; public ReservationService() { carFactory=new CarFactory(); } public Reservation getReservation(String carType) throws Exception { Car reservedCar=carFactory.getCar(carType); if (reservedCar==null) throw new Exception("car type not available"); Reservation reservation=new Reservation(); reservation.setReservedCar(reservedCar); return reservation; } public CarFactory getCarFactory() { return carFactory; } public void setCarFactory(CarFactory carFactory) { this.carFactory = carFactory; } }