Repository navigation
Expand file tree
/
Copy pathMancalaDesign.java
More file actions
83 lines (69 loc) · 2.13 KB
/
Copy pathMancalaDesign.java
File metadata and controls
83 lines (69 loc) · 2.13 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import java.awt.Color;
import java.awt.Shape;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Rectangle2D;
import java.awt.geom.RoundRectangle2D;
import java.util.ArrayList;
public class MancalaDesign implements Interface
{
public Shape getMancalaShape()
{
return new RoundRectangle2D.Double(25, 70,100,
200, 40, 40);
}
public Shape getPitShape()
{
return new Ellipse2D.Double(5, 5,110,
145);
}
public Shape [] getPitStoneShapes(int stoneAmount)
{
if (stoneAmount == 0)
return new Shape [] { new Rectangle2D.Double(0,0,0,0) };
ArrayList<Ellipse2D.Double> shapeList =
new ArrayList<Ellipse2D.Double>();
int dimension = (int) (Math.sqrt(stoneAmount) +2 );
int width = 110 / (dimension) - 10;
int height = 145 / (dimension) - 20;
for (int i = 0; i < stoneAmount; i++)
{
int xMod = (i % dimension);
int yMod = (i / dimension);
int x = xMod * (width + 4) + 18;
int y = yMod * (height + 4) + 30;
shapeList.add(new Ellipse2D.Double(x, y, width, height));
}
Ellipse2D.Double [] rectList = new Ellipse2D.Double[shapeList.size()];
rectList = shapeList.toArray(rectList);
return rectList;
}
public Shape [] getMancalaStoneShapes(int stoneAmount)
{
if (stoneAmount == 0)
return new Shape [] { new Rectangle2D.Double(0,0,0,0) };
ArrayList<Ellipse2D.Double> shapeList =
new ArrayList<Ellipse2D.Double>();
int dimension = (int) (Math.sqrt(stoneAmount) + 3);
int width = 100/ (dimension) - 7;
int height =200 / (dimension) - 7;
for (int i = 0; i < stoneAmount; i++)
{
int xMod = (i % dimension);
int yMod = (i / dimension);
int x = xMod * (width + 4) + 40;
int y = yMod * (height + 4) + 80;
shapeList.add(new Ellipse2D.Double(x, y, width, height));
}
Ellipse2D.Double [] rectList = new Ellipse2D.Double[shapeList.size()];
rectList = shapeList.toArray(rectList);
return rectList;
}
public Color getColor()
{
return Color.BLACK;
}
public Color getFillColor()
{
return Color.CYAN;
}
}