Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Decorator Pattern - Concrete Decorators
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