Skip to content

Commit

Permalink
fixed const
Browse files Browse the repository at this point in the history
  • Loading branch information
khorkovenko committed Oct 11, 2023
1 parent 22764b1 commit 40da0ce
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/Circle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
package core.basesyntax;

public interface FigurePainter {
public interface Drawable {
void draw();
}
5 changes: 2 additions & 3 deletions src/main/java/core/basesyntax/Figure.java
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/core/basesyntax/FigureSupplier.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
}
Expand All @@ -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;
}
}
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/IsoscelesTrapezoid.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/Rectangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/RightTriangle.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/Square.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down

0 comments on commit 40da0ce

Please sign in to comment.