/** * Enumeration for different types of cars. */staticenumCarType{FORD,FERRARI}/** * Factory method takes as parameter a car type and initiate the appropriate class. */publicstaticCargetCar(CarTypetype){switch(type){caseFORD:returnnewFord();caseFERRARI:returnnewFerrari();default:thrownewIllegalArgumentException("Model not supported.");}}