Skip to content

Commit

Permalink
added random color, random area and so on
Browse files Browse the repository at this point in the history
  • Loading branch information
bagouser123 committed Oct 5, 2023
1 parent 24943bc commit 28d975a
Show file tree
Hide file tree
Showing 7 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
@@ -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) {
Expand Down
17 changes: 3 additions & 14 deletions src/main/java/core/basesyntax/Figure.java
Original file line number Diff line number Diff line change
@@ -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();
}
2 changes: 1 addition & 1 deletion src/main/java/core/basesyntax/IsoscelesTrapezoid.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/core/basesyntax/Object.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
6 changes: 3 additions & 3 deletions src/main/java/core/basesyntax/Rectangle.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package core.basesyntax;

public class Rectangle extends Figure {
public class Rectangle extends Object {
private double length;
private double width;

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

public class Square extends Figure {
public class Square extends Object {
private String color;
private double sideLength;

Expand Down

0 comments on commit 28d975a

Please sign in to comment.