Factory-Method

Intent

Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.

定义一个用于创建对象的接口,让子类决定实例化哪一个类。 Factory Method使一个类的 实例化延迟到其子类。

Code

Code can be found on Github