diff --git a/src/main/java/core/basesyntax/Circle.java b/src/main/java/core/basesyntax/Circle.java index 13f1fe22ba..6123745e0a 100644 --- a/src/main/java/core/basesyntax/Circle.java +++ b/src/main/java/core/basesyntax/Circle.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class Circle extends Figure { +public class Circle extends Object { private double radius; public Circle(String color, double radius) { diff --git a/src/main/java/core/basesyntax/Figure.java b/src/main/java/core/basesyntax/Figure.java index 2617825289..8ea9d39ccc 100644 --- a/src/main/java/core/basesyntax/Figure.java +++ b/src/main/java/core/basesyntax/Figure.java @@ -1,17 +1,6 @@ package core.basesyntax; -public abstract class Figure { - private String color; - - public Figure(String color) { - this.color = color; - } - - public String getColor() { - return color; - } - - public abstract double getArea(); - - public abstract void draw(); +public interface Figure { + double getArea(); + void draw(); } diff --git a/src/main/java/core/basesyntax/IsoscelesTrapezoid.java b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java index 3eb0427f71..09955f5f3f 100644 --- a/src/main/java/core/basesyntax/IsoscelesTrapezoid.java +++ b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class IsoscelesTrapezoid extends Figure { +public class IsoscelesTrapezoid extends Object { private String color; private double upperBase; private double lowerBase; diff --git a/src/main/java/core/basesyntax/Object.java b/src/main/java/core/basesyntax/Object.java new file mode 100644 index 0000000000..4611d7d517 --- /dev/null +++ b/src/main/java/core/basesyntax/Object.java @@ -0,0 +1,12 @@ +package core.basesyntax; + +public abstract class Object implements Figure{ + private String color; + + public Object(String color){ + this.color = color; + } + public String getColor() { + return color; + } +} diff --git a/src/main/java/core/basesyntax/Rectangle.java b/src/main/java/core/basesyntax/Rectangle.java index 772246cfe7..bf08f8ce10 100644 --- a/src/main/java/core/basesyntax/Rectangle.java +++ b/src/main/java/core/basesyntax/Rectangle.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class Rectangle extends Figure { +public class Rectangle extends Object { private double length; private double width; @@ -18,7 +18,7 @@ public double getArea() { @Override public void draw() { System.out.println("Figure: rectangle, area: " + getArea() - + " sq. units, length: " + length - + " units, width: " + width + " units, color: " + getColor()); + + " sq. units, length: " + length + " units, width: " + + width + " units, color: " + getColor()); } } diff --git a/src/main/java/core/basesyntax/RightTriangle.java b/src/main/java/core/basesyntax/RightTriangle.java index 43161f6a27..7411eb1359 100644 --- a/src/main/java/core/basesyntax/RightTriangle.java +++ b/src/main/java/core/basesyntax/RightTriangle.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class RightTriangle extends Figure { +public class RightTriangle extends Object { private String color; private double base; private double height; diff --git a/src/main/java/core/basesyntax/Square.java b/src/main/java/core/basesyntax/Square.java index d49241b901..edf918b80a 100644 --- a/src/main/java/core/basesyntax/Square.java +++ b/src/main/java/core/basesyntax/Square.java @@ -1,6 +1,6 @@ package core.basesyntax; -public class Square extends Figure { +public class Square extends Object { private String color; private double sideLength;