diff --git a/src/main/java/core/basesyntax/Circle.java b/src/main/java/core/basesyntax/Circle.java index a76f5faa1b..6dbfbbeef2 100644 --- a/src/main/java/core/basesyntax/Circle.java +++ b/src/main/java/core/basesyntax/Circle.java @@ -4,7 +4,7 @@ public class Circle extends Figure { private double radius; public Circle(double radius, String color) { - super(color, 0); + super(color); this.radius = radius; this.setArea(getArea()); } diff --git a/src/main/java/core/basesyntax/FigurePainter.java b/src/main/java/core/basesyntax/Drawable.java similarity index 57% rename from src/main/java/core/basesyntax/FigurePainter.java rename to src/main/java/core/basesyntax/Drawable.java index 3b260a671f..d045270178 100644 --- a/src/main/java/core/basesyntax/FigurePainter.java +++ b/src/main/java/core/basesyntax/Drawable.java @@ -1,5 +1,5 @@ package core.basesyntax; -public interface FigurePainter { +public interface Drawable { void draw(); } diff --git a/src/main/java/core/basesyntax/Figure.java b/src/main/java/core/basesyntax/Figure.java index 8a9dd67f58..72a8bb0553 100644 --- a/src/main/java/core/basesyntax/Figure.java +++ b/src/main/java/core/basesyntax/Figure.java @@ -1,12 +1,11 @@ package core.basesyntax; -public abstract class Figure implements AreaCalculator, FigurePainter { +public abstract class Figure implements AreaCalculator, Drawable { private String color; private double area; - public Figure(String color, double area) { + public Figure(String color) { this.color = color; - this.area = area; } public String getColor() { diff --git a/src/main/java/core/basesyntax/FigureSupplier.java b/src/main/java/core/basesyntax/FigureSupplier.java index 9af13cf016..9125595a3e 100644 --- a/src/main/java/core/basesyntax/FigureSupplier.java +++ b/src/main/java/core/basesyntax/FigureSupplier.java @@ -4,6 +4,8 @@ public class FigureSupplier { private final int figuresCount = FigureType.values().length; + private final int radius = 10; + private final int length = 100; private final Random random = new Random(); private final ColorSupplier colorSupplier = new ColorSupplier(); @@ -13,27 +15,27 @@ public Figure getRandomFigure() { switch (randomFigureType) { case SQUARE: - figure = new Square(getRandomIn100to1Range(), + figure = new Square(getRandomLength(), colorSupplier.getRandomColor()); break; case RIGHT_TRIANGLE: - figure = new RightTriangle(getRandomIn100to1Range(), - getRandomIn100to1Range(), + figure = new RightTriangle(getRandomLength(), + getRandomLength(), colorSupplier.getRandomColor()); break; case RECTANGLE: - figure = new Rectangle(getRandomIn100to1Range(), - getRandomIn100to1Range(), + figure = new Rectangle(getRandomLength(), + getRandomLength(), colorSupplier.getRandomColor()); break; case ISOSCELES_TRAPEZOID: - figure = new IsoscelesTrapezoid(getRandomIn100to1Range(), - getRandomIn100to1Range(), - getRandomIn100to1Range(), + figure = new IsoscelesTrapezoid(getRandomLength(), + getRandomLength(), + getRandomLength(), colorSupplier.getRandomColor()); break; default: - figure = new Circle(getRandomIn100to1Range(), + figure = new Circle(getRandomLength(), colorSupplier.getRandomColor()); break; } @@ -42,10 +44,10 @@ public Figure getRandomFigure() { } public Figure getDefaultFigure() { - return new Circle(10, Color.WHITE.name()); + return new Circle(radius, Color.WHITE.name()); } - private int getRandomIn100to1Range() { - return random.nextInt(100) + 1; + private int getRandomLength() { + return random.nextInt(length) + 1; } } diff --git a/src/main/java/core/basesyntax/IsoscelesTrapezoid.java b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java index 50c52498b8..3d085c6cc1 100644 --- a/src/main/java/core/basesyntax/IsoscelesTrapezoid.java +++ b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java @@ -6,7 +6,7 @@ public class IsoscelesTrapezoid extends Figure { private double height; public IsoscelesTrapezoid(double topSide, double bottomSide, double height, String color) { - super(color, 0); + super(color); this.topSide = topSide; this.bottomSide = bottomSide; this.height = height; diff --git a/src/main/java/core/basesyntax/Rectangle.java b/src/main/java/core/basesyntax/Rectangle.java index ff4c9469f3..ad0d1b8317 100644 --- a/src/main/java/core/basesyntax/Rectangle.java +++ b/src/main/java/core/basesyntax/Rectangle.java @@ -5,7 +5,7 @@ public class Rectangle extends Figure { private double height; public Rectangle(double width, double height, String color) { - super(color, 0); + super(color); this.width = width; this.height = height; this.setArea(getArea()); diff --git a/src/main/java/core/basesyntax/RightTriangle.java b/src/main/java/core/basesyntax/RightTriangle.java index bc393636d4..f5842fdf2d 100644 --- a/src/main/java/core/basesyntax/RightTriangle.java +++ b/src/main/java/core/basesyntax/RightTriangle.java @@ -5,7 +5,7 @@ public class RightTriangle extends Figure { private double catSecond; public RightTriangle(double catFirst, double catSecond, String color) { - super(color, 0); + super(color); this.catFirst = catFirst; this.catSecond = catSecond; this.setArea(getArea()); diff --git a/src/main/java/core/basesyntax/Square.java b/src/main/java/core/basesyntax/Square.java index 8d7c0fe91c..3eabb9f247 100644 --- a/src/main/java/core/basesyntax/Square.java +++ b/src/main/java/core/basesyntax/Square.java @@ -4,7 +4,7 @@ public class Square extends Figure { private double side; public Square(double side, String color) { - super(color, 0); + super(color); this.side = side; this.setArea(getArea()); }