PIbd-23_Mochalov_D.V._Locom.../ExtraWheelsDraw.java

55 lines
1.6 KiB
Java

import java.awt.*;
public class ExtraWheelsDraw implements IDrawningExtra{
private WheelsCount wheelsCount = WheelsCount.Two;
public void setExtraNum(int num) {
switch (num) {
case 3: {
wheelsCount = WheelsCount.Three;
break;
}
case 4: {
wheelsCount = WheelsCount.Four;
break;
}
default:
break;
}
}
private Color color;
public void SetColor(Color color) {
this.color = color;
}
public ExtraWheelsDraw(int num, Color color) {
setExtraNum(num);
this.color = color;
}
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
g.setColor(Color.BLACK);
g.drawOval(startPosX, startPosY + 30, 20, 20);
g.drawOval(startPosX + 90, startPosY + 30, 20, 20);
g.setColor(Color.BLACK);
g.fillOval(startPosX, startPosY + 30, 20, 20);
g.fillOval(startPosX + 90, startPosY + 30, 20, 20);
switch (wheelsCount) {
case Four: {
g.setColor(color);
g.drawOval(startPosX + 70, startPosY + 30, 20, 20);
g.setColor(Color.BLACK);
g.fillOval(startPosX + 70, startPosY + 30, 20, 20);
}
case Three: {
g.fillOval(startPosX + 20, startPosY + 30, 20, 20);
g.setColor(color);
g.drawOval(startPosX + 20, startPosY + 30, 20, 20);
break;
}
default:
break;
}
}
}