Honeycombs: Difference between revisions
Content added Content deleted
(→{{header|Java}}: added Java) |
(→{{header|Java}}: improved code layout) |
||
Line 1,128: | Line 1,128: | ||
class HoneycombsPanel extends JPanel { |
class HoneycombsPanel extends JPanel { |
||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
Hexagon[] comb; |
Hexagon[] comb; |
||
Line 1,210: | Line 1,165: | ||
int x1 = 150, y1 = 100, x2 = 225, y2 = 143, w = 150, h = 87; |
int x1 = 150, y1 = 100, x2 = 225, y2 = 143, w = 150, h = 87; |
||
for (int i = 0; i < comb.length; i++) { |
for (int i = 0; i < comb.length; i++) { |
||
int x |
int x, y; |
||
if (i < 12) { |
|||
x = x1 + (i % 3) * w; |
|||
y = y1 + (i / 3) * h; |
|||
} else { |
|||
x = x2 + (i % 2) * w; |
|||
y = y2 + ((i - 12) / 2) * h; |
|||
⚫ | |||
comb[i] = new Hexagon(x, y, w / 3, letters[i]); |
comb[i] = new Hexagon(x, y, w / 3, letters[i]); |
||
} |
} |
||
Line 1,227: | Line 1,188: | ||
for (Hexagon hex : comb) |
for (Hexagon hex : comb) |
||
hex.draw(g); |
hex.draw(g); |
||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
} |
} |
||
}</lang> |
}</lang> |