package obesechild.agent.weightgainstrategy; /*********************************************** * The WeightGainStrategyCreator creates a specific * WeightGainStrategyProduct, depending on the type that * is passed through the factory method. * * The created object is returned by the factory class through * the DecisionStrategyProduct abstraction. * * [Factory Method Pattern of GoF] * * @author Meghan Hutchins * @dateCreated March 24, 2009 */ public class WeightGainStrategyCreator { /*********************************************** * Decide which weight gain strategy should be created * based on WeightGainStrategyType and return it. * * @return DecisionStrategyProduct */ public WeightGainStrategyProduct createStrategyProduct(WeightGainStrategyType type) { WeightGainStrategyProduct strategy; switch(type) { case RANDOM: strategy = new RandomStrategyProduct(); break; case WEIGHT: strategy = new WeightStrategyProduct(); break; case INCREMENT: strategy = new IncrementStrategyProduct(); break; default: // Default strategy is NoGain. strategy = new NoGainStrategyProduct(); break; } return strategy; } }