简单工厂模式-java实现
2021-08-05 11:56
标签:override 简单 str new ace string actor sys lang 简单工厂模式 Shape.java public interface Shape { void draw(); } Circle.java public class Circle implements Shape{ @Override public void draw() { System.out.println("i‘m a circle"); } } Rectangle.java public class Rectangle implements Shape{ @Override public void draw() { System.out.println("i‘m a rectangle"); } } 工厂类ShapeFactory.java public class ShapeFactory { public static Shape getShape(String name) { if ("circle".equals(name)) { return new Circle(); } if ("rectangle".equals(name)) { return new Rectangle(); } return null; } } 简单工厂模式-java实现标签:override 简单 str new ace string actor sys lang 原文地址:https://www.cnblogs.com/wishee/p/14952181.html
上一篇:map reduce 用法 str处理lower() capitalize()
下一篇:读后:Large Motion Video Super-Resolution with Dual Subnet and Multi-Stage Communicated Upsampling