Created
February 15, 2021 18:15
-
-
Save anjanashankar9/0f2685cfbc2009b72f9bf33bd962d898 to your computer and use it in GitHub Desktop.
Decorator Pattern - Concrete Decorators
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FillColor extends ShapeDecorator { | |
String color; | |
public FillColor(Shape decoratedShape, String color) { | |
super(decoratedShape); | |
this.color = color; | |
} | |
@Override | |
public void draw() { | |
decoratedShape.draw(); | |
setColor(); | |
} | |
private void setColor(){ | |
System.out.println("Color: "+color); | |
} | |
} | |
public class BorderThickness extends ShapeDecorator { | |
Integer borderThickness; | |
public BorderThickness(Shape decoratedShape, Integer thickness) { | |
super(decoratedShape); | |
this.borderThickness = thickness; | |
} | |
@Override | |
public void draw() { | |
decoratedShape.draw(); | |
setThickness(); | |
} | |
private void setThickness(){ | |
System.out.println("Border Width: "+borderThickness); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment