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.
- Loading branch information
Showing
7 changed files
with
43 additions
and
12 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
|
||
public interface FigureMethods { | ||
double area(); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,21 @@ | ||
package core.basesyntax; | ||
|
||
public class FigureSupplier { | ||
public Figure getRandomFigure() { | ||
import java.util.Random; | ||
|
||
} | ||
public class FigureSupplier extends ColorSupplier { | ||
private final static Random picker = new Random(); | ||
|
||
public Figure getDefaultFigure() { | ||
public static Figure getRandomFigure() { | ||
return switch(picker.nextInt(4)) { | ||
case 0 -> new Circle(getRandomColor(), picker.nextInt(1, 50)); | ||
case 1 -> new Rectangle(getRandomColor(), picker.nextInt(1, 50), picker.nextInt(1, 50)); | ||
case 2 -> new RightTriangle(getRandomColor(), picker.nextInt(1, 50), picker.nextInt(1, 50)); | ||
case 3 -> new Square(getRandomColor(), picker.nextInt(1, 50)); | ||
default -> new Circle(Colors.WHITE, 10); | ||
}; | ||
} | ||
|
||
public static Figure getDefaultFigure() { | ||
return new Circle(Colors.WHITE, 10); | ||
} | ||
} |
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