I need a factory like method that popoulate the same object according to parameter passed. Something like this:
Car output = CarFactory.getCar(EnumCarType.FAST_CAR)
CarFactory
public static Car getCar(EnumCarType type) {
Car car= new Car();
switch (type) {
case FAST_CAR:
car.setSpeed(200);
car.setGears(7);
...
break;
case SLOW_CAR:
car.setSpeed(120);
car.setGears(5);
...
break;
}
return car;
}
As you can see is not a properly factory because I need to return only one type of object so I don't need any kind of abstraction.
Can you help me identifying the right pattern case?
Aucun commentaire:
Enregistrer un commentaire