package cn.datax.learning.design.patterns.creational.factory.method;

import cn.datax.learning.design.patterns.creational.factory.Color;

/**
 * 工厂模式（Factory Pattern）
 * 2.工厂方法模式
 */
public class FactoryMethodDemo {

    public static void main(String[] args) {
        ColorFactory colorFactory1 = new RedFactory();
        Color color1 = colorFactory1.getColor();
        color1.fill();

        ColorFactory colorFactory2 = new GreenFactory();
        Color color2 = colorFactory2.getColor();
        color2.fill();

        ColorFactory colorFactory3 = new BlueFactory();
        Color color3 = colorFactory3.getColor();
        color3.fill();
    }
}
