publicclassCalculatorFactory{privatestaticfinalStringIMPL_CLASS="pr2.impl.CalculatorImpl";privateCalculatorFactory(){}publicstaticCalculatorcreateCalculator(){Class<?>clazz;try{clazz=Class.forName(IMPL_CLASS);return(Calculator)clazz.newInstance();}catch(ClassNotFoundExceptione){thrownewIllegalStateException(IMPL_CLASS+" nicht gefunden");}catch(InstantiationExceptione){thrownewIllegalStateException(IMPL_CLASS+" hat einen Fehler geworfen: "+e);}catch(IllegalAccessExceptione){thrownewIllegalStateException(IMPL_CLASS+" hat keinen public Konstruktor");}}}