(创建型模式二)工厂方法模式

来源:互联网 发布:网口数据监控软件 编辑:程序博客网 时间:2024/05/16 11:23
package com.eyugame.modle;/** * 工厂方法模式 * @author JYC506 * */public class Factory implements IFactory {@Overridepublic IProduct createProduct() {return new Product();}    }interface IFactory{IProduct createProduct();}interface IProduct{public void show();}class Product implements IProduct{@Overridepublic void show() {System.out.println("我是产品");}}class Test{public static void main(String[] args) {Factory factory =new Factory();IProduct product=factory.createProduct();product.show();}}


0 0
原创粉丝点击