我是一个大二学生希望你能给我利用简单工厂设计模式参考以下给定的代码设计一个测试程序。 interface Fruit 定义一个水果的接口 public void eat ; 吃水果的方法 class Apple implements Fruit 定义子类 —— Apple public void eat ……………… class Orange implements Frui
public class Test { public static void main(String[] args) { Fruit apple = Factory.getInstance("apple"); apple.eat();
Fruit orange = Factory.getInstance("orange");
orange.eat();
}
}
原文地址: http://www.cveoy.top/t/topic/bs5x 著作权归作者所有。请勿转载和采集!