diff --git a/src/shapes/App.java b/src/shapes/App.java deleted file mode 100644 index 1ef07d367623cf847655394b6fbf0ab9764c5c86..0000000000000000000000000000000000000000 --- a/src/shapes/App.java +++ /dev/null @@ -1,32 +0,0 @@ -package shapes; - -public class App { - public static void main(String[] args) { - Circle c1 = new Circle(5.0); - Rectangle r1 = new Rectangle(2.0, 10.0); - Circle c2 = new Circle(20.0); - Rectangle r2 = new Rectangle(23.0, 100.0); - RectangleCircle rc1 = new RectangleCircle(10.0, 25.0, 30.0); - - System.out.println("First circle area: " + c1.area()); - System.out.println("First circle circumference: " + c1.circumference()); - System.out.println("First rectangle area: " + r1.area()); - System.out.println("First rectangle circumference: " + r1.circumference()); - System.out.println("First rectangle circle area: " + rc1.area()); - System.out.println("First rectangle circle circumference: " + rc1.circumference()); - - Shape[] shapes = new Shape[10]; - shapes[0] = c1; - shapes[1] = c2; - shapes[2] = r1; - shapes[3] = r2; - shapes[4] = rc1; - - System.out.println("Accumulation of areas: " + Util.accumulateArea(shapes)); - System.out.println("Accumulation of circumferences: " + Util.accumulateCircumference(shapes)); - - Object[] objects = shapes; - System.out.println("Accumulation of areas: " + Util.accumulateArea(objects)); - System.out.println("Accumulation of circumferences: " + Util.accumulateCircumference(objects)); - } -} diff --git a/src/shapes/Circle.java b/src/shapes/Circle.java deleted file mode 100644 index 6bb53aaac8852e266e4908e010d9cf3ccfffb792..0000000000000000000000000000000000000000 --- a/src/shapes/Circle.java +++ /dev/null @@ -1,29 +0,0 @@ -package shapes; - -import static java.lang.Math.PI; - -public class Circle implements Shape { - private double radius; - - public Circle(double radius) { - this.radius = radius; - } - - @Override - public double area() { - return PI * radius * radius; - } - - @Override - public double circumference() { - return 2 * PI * radius; - } - - public double getRadius() { - return radius; - } - - public void setRadius(double radius) { - this.radius = radius; - } -} diff --git a/src/shapes/Rectangle.java b/src/shapes/Rectangle.java deleted file mode 100644 index dff0a71eb4d12dce70439f5ea8c2e2556cbd755b..0000000000000000000000000000000000000000 --- a/src/shapes/Rectangle.java +++ /dev/null @@ -1,38 +0,0 @@ -package shapes; - -public class Rectangle implements Shape { - - private double width; - private double height; - - public Rectangle(double width, double height) { - this.width = width; - this.height = height; - } - - @Override - public double area() { - return width * height; - } - - @Override - public double circumference() { - return 2 * width + 2 * height; - } - - public void setWidth(double width) { - this.width = width; - } - - public double getWidth() { - return width; - } - - public void setHeight(double height) { - this.height = height; - } - - public double getHeight() { - return height; - } -} diff --git a/src/shapes/RectangleCircle.java b/src/shapes/RectangleCircle.java deleted file mode 100644 index cd3450f7a5758e271407043e99adf7841e95968d..0000000000000000000000000000000000000000 --- a/src/shapes/RectangleCircle.java +++ /dev/null @@ -1,45 +0,0 @@ -package shapes; - -public class RectangleCircle implements Shape { - private Circle c; - private Rectangle r; - - public RectangleCircle(double radius, double width, double height) { - c = new Circle(radius); - r = new Rectangle(width, height); - } - - @Override - public double area() { - return r.area() - c.area(); - } - - @Override - public double circumference() { - return r.circumference() + c.circumference(); - } - - public void setRadius(double radius) { - c.setRadius(radius); - } - - public double getRadius() { - return c.getRadius(); - } - - public void setWidth(double width) { - r.setWidth(width); - } - - public double getWidth() { - return r.getWidth(); - } - - public void setHeight(double height) { - r.setHeight(height); - } - - public double getHeight() { - return r.getHeight(); - } -} \ No newline at end of file diff --git a/src/shapes/Shape.java b/src/shapes/Shape.java deleted file mode 100644 index 332442ae17e6e13b1734352848773505c408cf69..0000000000000000000000000000000000000000 --- a/src/shapes/Shape.java +++ /dev/null @@ -1,6 +0,0 @@ -package shapes; - -public interface Shape { - double area(); - double circumference(); -} diff --git a/src/shapes/Util.java b/src/shapes/Util.java deleted file mode 100644 index 004b280f732f12b1cf2a0bf6c62ae7a55fd358b1..0000000000000000000000000000000000000000 --- a/src/shapes/Util.java +++ /dev/null @@ -1,57 +0,0 @@ -package shapes; - -public class Util { - public static double accumulateArea(Shape[] shapes) { - double result = 0.0; - for (Shape shape : shapes) { - if (shape != null) - result += shape.area(); - } - return result; - } - - public static double accumulateCircumference(Shape[] shapes) { - double result = 0.0; - for (Shape shape : shapes) { - if (shape != null) - result += shape.circumference(); - } - return result; - } - - public static double accumulateArea(Object[] objects) { - double result = 0.0; - for (Object object : objects) { - if (object != null) { - if (object instanceof Rectangle) { - result += ((Rectangle) object).area(); - } - if (object instanceof Circle) { - result += ((Circle) object).area(); - } - if (object instanceof RectangleCircle) { - result += ((RectangleCircle) object).area(); - } - } - } - return result; - } - - public static double accumulateCircumference(Object[] objects) { - double result = 0.0; - for (Object object : objects) { - if (object != null) { - if (object instanceof Rectangle) { - result += ((Rectangle) object).circumference(); - } - if (object instanceof Circle) { - result += ((Circle) object).circumference(); - } - if (object instanceof RectangleCircle) { - result += ((RectangleCircle) object).circumference(); - } - } - } - return result; - } -}