Last active
June 11, 2020 20:02
-
-
Save sasssass/301cdf48c285278a449ffac9d11ffce0 to your computer and use it in GitHub Desktop.
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 final class Shape { | |
public float perimeter; | |
public float area; | |
public int color; | |
public String name; | |
private Shape(ShapeBuilder builder) { | |
perimeter = builder.perimeter; | |
area = builder.area; | |
color = builder.color; | |
name = builder.name; | |
} | |
public static class ShapeBuilder implements ShapeBuilderInterface { | |
public ShapeBuilder(float perimeter,float area){ | |
this.perimeter = perimeter; | |
this.area = area; | |
} | |
private float perimeter; | |
private float area; | |
public int color = 0; | |
public String name = "undefined"; | |
@Override | |
public ShapeBuilder addColor(int color) { | |
this.color = color; | |
return this; | |
} | |
@Override | |
public ShapeBuilder addName(String name) { | |
this.name = name; | |
return this; | |
} | |
public Shape build(){ | |
return new Shape(this); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment