-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientLight.java
More file actions
58 lines (43 loc) · 1.83 KB
/
ClientLight.java
File metadata and controls
58 lines (43 loc) · 1.83 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package flyweightDesign;
import java.awt.Color;
public class ClientLight {
private static final int WIDTH = 1800, HEIGHT = 1600;
//rc=rectangle, tr=triangle, sq=square, ci=circle, ov=oval, pa=parallelogram, he=hexagon, sp=sphere
private static final String shapes[] = { "rc", "tr", "sq", "ci", "ov", "pa", "he", "sp"};
private static final Color colors[] = { Color.red, Color.green, Color.blue, Color.darkGray };
private static final boolean fill[] = { true, false };
public static void main(String[] args) {
ClientLight client = new ClientLight();
}
public ClientLight() {
for(int i = 0; i < 1000; ++i) {
//Your code for ShapeFactory and generating random values for different variables
IShapeInterface shape = ShapeFactory.getShape(getRandomShape());
}
}
private static String getRandomShape() {
return shapes[(int) (Math.random() * shapes.length)];
}
private int getRandomX() {
return (int) (Math.random() * WIDTH*0.9);
}
private int getRandomY()
{
return (int) (Math.random() * HEIGHT*0.8);
}
private int getRandomWidth()
{
return (int) (Math.random() * (WIDTH / 7));}
private int getRandomHeight() {
return (int) (Math.random() * (HEIGHT / 7));
}
private Color getRandomColor() {
return colors[(int) (Math.random() * colors.length)];
}
private boolean getRandomFill() {
return fill[(int) (Math.random() * fill.length)];
}
public String toString() {
return "Shape"+ this.getRandomShape()+ "X: " + this.getRandomX()+"Y:"+ this.getRandomY()+"Width:"+ this.getRandomWidth()+"Height" +this.getRandomHeight()+"Color: " + this.getRandomColor()+ "Fill: " + this.getRandomFill();
}
}