staticfinal String DESCRIPTION = "This is the Elven Army!";
@Override public String getDescription(){ return DESCRIPTION; } }
/** * The Abstract Factory pattern provides a way to encapsulate a group of individual factories that * have a common theme without specifying their concrete classes. In normal usage, the client * software creates a concrete implementation of the abstract factory and then uses the generic * interface of the factory to create the concrete objects that are part of the theme. The client * does not know (or care) which concrete objects it gets from each of these internal factories, * since it uses only the generic interfaces of their products. This pattern separates the details * of implementation of a set of objects from their general usage and relies on object composition, * as object creation is implemented in methods exposed in the factory interface. * * <p>The essence of the Abstract Factory pattern is a factory interface ({@link KingdomFactory}) * and its implementations ( {@link ElfKingdomFactory}, {@link OrcKingdomFactory}). The example uses * both concrete implementations to create a king, a castle and an army. 抽象工厂模式提供了一种封装一组具有共同主题的单个工厂而无需指定其具体类的方法。在正常使用中,客户端软件会创建抽象工厂的具体实现,然后使用工厂的通用接口来创建作为主题一部分的具体对象。客户端不知道(或不在乎)它从这些内部工厂中获得了哪些具体对象,因为客户端仅使用其产品的通用接口。这种模式将一组对象的实现细节与它们的一般用法分开,并依赖于对象组成,因为对象创建是在工厂接口中公开的方法中实现的。 <p>抽象工厂模式的本质是工厂接口({@link KingdomFactory})及其实现({@link ElfKingdomFactory},{@ link OrcKingdomFactory})。 该示例使用两种具体实现来创建国王,城堡和军队。 */ publicclassApp{