We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
abstract class Shape { } class Circle extends Shape { } Circle circle = new Circle();
enum ShapeType { CIRCLE, RECTANGLE } public abstract class Shape { private ShapeType shapeType = null; public Shape(ShapeType shapeType) { this.shapeType = shapeType; } // 도형 생성 protected abstract void generate(); } class Rectangle extends Shape { Rectangle() { super(ShapeType.RECTANGLE); } @Override protected void generate() { System.out.println("Generate Rectangle"); } } class Circle extends Shape { Circle() { super(ShapeType.CIRCLE); } @Override protected void generate() { System.out.println("Generate Circle"); } } class ShapeFactory { public static Shape generateShape(final ShapeType shapeType) { Shape shape = null; switch (shapeType) { case RECTANGLE: shape = new Rectangle(); break; case CIRCLE: shape = new Circle(); break; default: break; } return shape; } } class TestFactoryPattern { public static void main(String[] args) { ShapeFactory.generateShape(ShapeType.RECTANGLE); ShapeFactory.generateShape(ShapeType.CIRCLE); } }
https://github.com/jh-dev-study/object-oriented-thinking-process/blob/main/10.%20%EB%94%94%EC%9E%90%EC%9D%B8%20%ED%8C%A8%ED%84%B4.md
The text was updated successfully, but these errors were encountered:
No branches or pull requests
DNS(Domain Name System)
팩토리 메서드 디자인 패턴
https://github.com/jh-dev-study/object-oriented-thinking-process/blob/main/10.%20%EB%94%94%EC%9E%90%EC%9D%B8%20%ED%8C%A8%ED%84%B4.md
The text was updated successfully, but these errors were encountered: