34 lines
1021 B
Java
34 lines
1021 B
Java
import java.awt.*;
|
|
|
|
public class DrawingTriDecks implements IDrawingDecks {
|
|
private DecksCount decksCount;
|
|
private Color color;
|
|
|
|
public DrawingTriDecks(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.fillPolygon(new int[] {x, x, x + 5}, new int[] {y + 5, y + 10, y + 10}, 3);
|
|
}
|
|
case Three: {
|
|
g.fillPolygon(new int[] {x + shipWidth - 20, x + shipWidth - 20, x + shipWidth}, new int[] {y, y + 10, y + 10}, 3);
|
|
}
|
|
}
|
|
}
|
|
} |