diff --git a/pom.xml b/pom.xml
index 0f8dd56657..735ad20850 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,13 @@
junit
junit
- 4.12
+ 4.13.1
+ test
+
+
+ org.junit.jupiter
+ junit-jupiter
+ RELEASE
test
@@ -42,7 +48,6 @@
${maven.checkstyle.plugin.configLocation}
- UTF-8
true
true
false
@@ -61,8 +66,13 @@
${project.build.sourceEncoding}
+
+
+
+
+
diff --git a/src/main/java/core/basesyntax/AreaCalculator.java b/src/main/java/core/basesyntax/AreaCalculator.java
new file mode 100644
index 0000000000..673262c690
--- /dev/null
+++ b/src/main/java/core/basesyntax/AreaCalculator.java
@@ -0,0 +1,5 @@
+package core.basesyntax;
+
+public interface AreaCalculator {
+ double getArea();
+}
diff --git a/src/main/java/core/basesyntax/Circle.java b/src/main/java/core/basesyntax/Circle.java
new file mode 100644
index 0000000000..6351a7ede6
--- /dev/null
+++ b/src/main/java/core/basesyntax/Circle.java
@@ -0,0 +1,22 @@
+package core.basesyntax;
+
+public class Circle extends Figure {
+ private int radius;
+
+ public Circle(String color, int radius) {
+ super(color);
+ this.radius = radius;
+ }
+
+ @Override
+ public double getArea() {
+ return Math.PI * radius * radius;
+ }
+
+ @Override
+ public void draw() {
+ System.out.println("Figure: circle, area: " + getArea() + " sq. units, radius: "
+ + radius + " units, color: " + getColor());
+ }
+
+}
diff --git a/src/main/java/core/basesyntax/ColorSupplier.java b/src/main/java/core/basesyntax/ColorSupplier.java
new file mode 100644
index 0000000000..ab2c828641
--- /dev/null
+++ b/src/main/java/core/basesyntax/ColorSupplier.java
@@ -0,0 +1,13 @@
+package core.basesyntax;
+
+import java.util.Random;
+
+class ColorSupplier {
+ private static final Random random = new Random();
+
+ public String getRandomColor() {
+ int index = random.nextInt(Colors.values().length);
+ Colors colors = Colors.values()[index];
+ return colors.name();
+ }
+}
diff --git a/src/main/java/core/basesyntax/Colors.java b/src/main/java/core/basesyntax/Colors.java
new file mode 100644
index 0000000000..ae0a0ba318
--- /dev/null
+++ b/src/main/java/core/basesyntax/Colors.java
@@ -0,0 +1,5 @@
+package core.basesyntax;
+
+enum Colors {
+ RED, GREEN, WHITE, BLACK, BLUE;
+}
diff --git a/src/main/java/core/basesyntax/Drawable.java b/src/main/java/core/basesyntax/Drawable.java
new file mode 100644
index 0000000000..d045270178
--- /dev/null
+++ b/src/main/java/core/basesyntax/Drawable.java
@@ -0,0 +1,5 @@
+package core.basesyntax;
+
+public interface Drawable {
+ void draw();
+}
diff --git a/src/main/java/core/basesyntax/Figure.java b/src/main/java/core/basesyntax/Figure.java
new file mode 100644
index 0000000000..a7437db5a2
--- /dev/null
+++ b/src/main/java/core/basesyntax/Figure.java
@@ -0,0 +1,14 @@
+package core.basesyntax;
+
+public abstract class Figure implements AreaCalculator, Drawable {
+ private String color;
+
+ public Figure(String color) {
+ this.color = color;
+ }
+
+ public String getColor() {
+ return color;
+ }
+
+}
diff --git a/src/main/java/core/basesyntax/FigureSupplier.java b/src/main/java/core/basesyntax/FigureSupplier.java
new file mode 100644
index 0000000000..1f76ac2e31
--- /dev/null
+++ b/src/main/java/core/basesyntax/FigureSupplier.java
@@ -0,0 +1,42 @@
+package core.basesyntax;
+
+import java.util.Random;
+
+public class FigureSupplier {
+ public static final int FIGURE_COUNT = 5;
+ private static final Random random = new Random();
+ private static final ColorSupplier colorSupplier = new ColorSupplier();
+
+ public Figure getRandomFigure() {
+ final int figureType = random.nextInt(FIGURE_COUNT);
+ String color = colorSupplier.getRandomColor();
+ int sideOrRadius = random.nextInt() * 10;
+ switch (figureType) {
+ case 0:
+ return new Square(color, sideOrRadius);
+ case 1:
+ return new Circle(color, sideOrRadius);
+ case 2:
+ double width = random.nextDouble() * 10;
+ double height = random.nextDouble() * 10;
+ return new Rectangle(color, (int) width, (int) height);
+ case 3:
+ double firstLeg = random.nextDouble() * 10;
+ double secondLeg = random.nextDouble() * 10;
+ return new RightTriangle(color, (int) secondLeg, (int) firstLeg);
+ case 4:
+ int topBase = random.nextInt() * 10;
+ int bottomBase = random.nextInt() * 10;
+ int heightTrapezoid = random.nextInt() * 10;
+ return new IsoscelesTrapezoid(color, topBase, bottomBase, heightTrapezoid);
+
+ default:
+ return getDefaultFigure();
+ }
+
+ }
+
+ public Figure getDefaultFigure() {
+ return new Circle("white", 10);
+ }
+}
diff --git a/src/main/java/core/basesyntax/HelloWorld.java b/src/main/java/core/basesyntax/HelloWorld.java
deleted file mode 100644
index 97db782bf7..0000000000
--- a/src/main/java/core/basesyntax/HelloWorld.java
+++ /dev/null
@@ -1,8 +0,0 @@
-package core.basesyntax;
-
-/**
- * Feel free to remove this class and create your own.
- */
-public class HelloWorld {
-
-}
diff --git a/src/main/java/core/basesyntax/IsoscelesTrapezoid.java b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java
new file mode 100644
index 0000000000..44c42de894
--- /dev/null
+++ b/src/main/java/core/basesyntax/IsoscelesTrapezoid.java
@@ -0,0 +1,27 @@
+package core.basesyntax;
+
+public class IsoscelesTrapezoid extends Figure {
+ private int base1;
+ private int base2;
+ private int height;
+
+ public IsoscelesTrapezoid(String color, int base1, int base2, int height) {
+ super(color);
+ this.base1 = base1;
+ this.base2 = base2;
+ this.height = height;
+ }
+
+ @Override
+ public double getArea() {
+ return ((double) (base1 + base2) / 2) * height;
+ }
+
+ @Override
+ public void draw() {
+ System.out.println("Figure: isoscelesTrapezoid, area: " + getArea()
+ + " sq. units, base1: "
+ + base1 + "base2" + base2 + " units, color: " + getColor());
+ }
+
+}
diff --git a/src/main/java/core/basesyntax/Main.java b/src/main/java/core/basesyntax/Main.java
new file mode 100644
index 0000000000..d9cdb02f13
--- /dev/null
+++ b/src/main/java/core/basesyntax/Main.java
@@ -0,0 +1,16 @@
+package core.basesyntax;
+
+public class Main {
+ public static void main(String[] args) {
+ FigureSupplier figureSupplier = new FigureSupplier();
+ Figure[] figures = new Figure[6];
+ for (int i = 0; i < 6; i++) {
+ figures[i] = figureSupplier.getRandomFigure();
+ figures[i].draw();
+
+ }
+
+ }
+}
+
+
diff --git a/src/main/java/core/basesyntax/Rectangle.java b/src/main/java/core/basesyntax/Rectangle.java
new file mode 100644
index 0000000000..2b464e50a1
--- /dev/null
+++ b/src/main/java/core/basesyntax/Rectangle.java
@@ -0,0 +1,26 @@
+package core.basesyntax;
+
+public class Rectangle extends Figure {
+ private int width;
+ private int height;
+
+ public Rectangle(String color, int width, int height) {
+ super(color);
+ this.width = width;
+ this.height = height;
+
+ }
+
+ @Override
+ public double getArea() {
+ return width * height;
+
+ }
+
+ @Override
+ public void draw() {
+ System.out.println("Figure: rectangle, area: " + getArea() + " sq. units, width: "
+ + width + " units, height: " + height + " units, color: " + getColor());
+ }
+
+}
diff --git a/src/main/java/core/basesyntax/RightTriangle.java b/src/main/java/core/basesyntax/RightTriangle.java
new file mode 100644
index 0000000000..5182c98e46
--- /dev/null
+++ b/src/main/java/core/basesyntax/RightTriangle.java
@@ -0,0 +1,24 @@
+package core.basesyntax;
+
+public class RightTriangle extends Figure {
+ private int firstLeg;
+ private int secondLeg;
+
+ public RightTriangle(String color, int firstLeg, int secondLeg) {
+ super(color);
+ this.firstLeg = firstLeg;
+ this.secondLeg = secondLeg;
+ }
+
+ @Override
+ public double getArea() {
+ return 0;
+ }
+
+ @Override
+ public void draw() {
+ System.out.println("Figure: rectangle, area: " + getArea() + " sq. units, firstLeg: "
+ + firstLeg + " units, secondLeg: " + secondLeg + " units, color: " + getColor());
+ }
+
+}
diff --git a/src/main/java/core/basesyntax/Square.java b/src/main/java/core/basesyntax/Square.java
new file mode 100644
index 0000000000..1c3222a5bf
--- /dev/null
+++ b/src/main/java/core/basesyntax/Square.java
@@ -0,0 +1,23 @@
+package core.basesyntax;
+
+public class Square extends Figure {
+ private double side;
+
+ public Square(String color, double side) {
+ super(color);
+ this.side = side;
+
+ }
+
+ @Override
+ public double getArea() {
+ return side * side;
+ }
+
+ @Override
+ public void draw() {
+ System.out.println("Figure: square, area: " + getArea() + " sq. units, side: " + side
+ + " units, color: " + getColor());
+ }
+
+}