generated from mate-academy/jv-homework-template
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added random color, random area and so on
- Loading branch information
1 parent
b7bbafd
commit 0e93e7c
Showing
7 changed files
with
32 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,23 @@ | ||
package core.basesyntax; | ||
|
||
public class Circle implements Figure { | ||
private String color; | ||
public class Circle extends Figure { | ||
private double radius; | ||
|
||
public Circle(String color, double radius) { | ||
this.color = color; | ||
super(color); | ||
this.radius = radius; | ||
} | ||
|
||
@Override | ||
public double getArea() { | ||
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:" + color); | ||
System.out.println("Figure: circle, area: " + getArea() | ||
+ " sq. units, radius: " + radius + " units, color: " + getColor()); | ||
} | ||
|
||
// Інші методи, специфічні для кола | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
package core.basesyntax; | ||
|
||
public interface Figure { | ||
public abstract class Figure { | ||
private String color; | ||
|
||
double getArea(); | ||
public Figure(String color) { | ||
this.color = color; | ||
} | ||
|
||
void draw(); | ||
} | ||
public String getColor() { | ||
return color; | ||
} | ||
|
||
public abstract double getArea(); | ||
public abstract void draw(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters