36 lines
1.1 KiB
Java
36 lines
1.1 KiB
Java
import java.awt.*;
|
|
|
|
public class DrawingRoundDecks implements IDrawingDecks {
|
|
private DecksCount decksCount;
|
|
private Color color;
|
|
|
|
public DrawingRoundDecks(int decksCount, Color bodyColor) {
|
|
setDecksCount(decksCount);
|
|
color = bodyColor;
|
|
}
|
|
|
|
public void setDecksCount(int num) {
|
|
if (num <= 1) {
|
|
decksCount = DecksCount.One;
|
|
} else if (num >= 3) {
|
|
decksCount = DecksCount.Three;
|
|
}
|
|
else {
|
|
decksCount = DecksCount.Two;
|
|
}
|
|
}
|
|
|
|
public void draw(Graphics2D g, int x, int y, int shipWidth, int shipHeight) {
|
|
g.setColor(color != null ? color : Color.BLACK);
|
|
switch (decksCount) {
|
|
case Two: {
|
|
g.fillRect(x, y + 5, 15, 5);
|
|
g.fillPolygon(new int[] {x, x, x + 5}, new int[] {y + 5, y + 10, y + 10}, 3);
|
|
}
|
|
case Three: {
|
|
g.fillRect(x + shipWidth - 20, y, 20, 10);
|
|
g.fillPolygon(new int[] {x + shipWidth - 20, x + shipWidth - 20, x + shipWidth - 25}, new int[] {y, y + 10, y + 10}, 3);
|
|
}
|
|
}
|
|
}
|
|
} |