2022-11-21 23:52:48 +04:00
|
|
|
import java.awt.*;
|
|
|
|
|
2022-12-06 17:23:28 +04:00
|
|
|
public class DrawningBlocks implements IDrawningBlocks {
|
|
|
|
private DirectionBlocksOnDeck blocksCount = DirectionBlocksOnDeck.Two;
|
2022-11-21 23:52:48 +04:00
|
|
|
private Color color;
|
2022-12-06 17:23:28 +04:00
|
|
|
public DrawningBlocks(int count, Color color){
|
|
|
|
SetBlocks(count);
|
2022-11-21 23:52:48 +04:00
|
|
|
this.color = color;
|
2022-12-06 17:23:28 +04:00
|
|
|
}
|
|
|
|
@Override
|
|
|
|
public void DrawBlocks(Graphics g, int x, int y, Color bodyColor) {
|
|
|
|
g.setColor(color != null ? color : Color.BLACK);
|
|
|
|
switch (blocksCount) {
|
|
|
|
case Four -> {
|
|
|
|
g.fillRect(x + 58, y, 8, 5);
|
|
|
|
g.fillRect(x + 70, y, 8, 5);
|
|
|
|
g.fillRect(x + 70, y + 40, 8, 5);
|
|
|
|
g.fillRect(x + 58, y + 40, 8, 5);
|
|
|
|
}
|
|
|
|
case Six -> {
|
|
|
|
g.fillRect(x + 46, y, 8, 5);
|
|
|
|
g.fillRect(x + 58, y , 8, 5);
|
|
|
|
g.fillRect(x + 70, y, 8, 5);
|
|
|
|
g.fillRect(x + 46, y + 45, 8, 5);
|
|
|
|
g.fillRect(x + 58, y + 45, 8, 5);
|
|
|
|
g.fillRect(x + 70, y + 45, 8, 5);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void SetBlocks(int count) {
|
|
|
|
switch(count)
|
|
|
|
{
|
|
|
|
case 4:
|
|
|
|
blocksCount = DirectionBlocksOnDeck.Four;
|
|
|
|
break;
|
|
|
|
case 6:
|
|
|
|
blocksCount = DirectionBlocksOnDeck.Six;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2022-11-21 23:52:48 +04:00
|
|
|
}
|