forked from MohammadSianaki/Design-Pattern-In-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.java
More file actions
27 lines (21 loc) · 714 Bytes
/
Copy pathTest.java
File metadata and controls
27 lines (21 loc) · 714 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class Test {
private static final String[] COLOR = {"RED", "BLUE", "GREEN", "BLACK", "YELLOW"};
public static void main(String[] args) {
for (int i = 0; i < 20; i++) {
Circle circle = (Circle) ShapeFactory.makeShape(getRandomColor());
circle.setRadius(100);
circle.setX(getRandomX());
circle.setY(getRandomY());
circle.draw();
}
}
private static String getRandomColor() {
return COLOR[(int) (Math.random() * COLOR.length)];
}
private static int getRandomX() {
return (int) (Math.random() * 100);
}
private static int getRandomY() {
return (int) (Math.random() * 100);
}
}