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

65 lines
1.8 KiB
Java
Raw Permalink Normal View History

2022-09-25 13:45:19 +04:00
import java.awt.*;
public class ExtraWheelsDraw implements IDrawningExtra{
2022-09-27 16:26:05 +04:00
private WheelsCount wheelsCount = WheelsCount.Two;
public void setExtraNum(int num) {
2022-09-27 16:26:05 +04:00
switch (num) {
case 3: {
2022-09-25 13:45:19 +04:00
wheelsCount = WheelsCount.Three;
break;
}
case 4: {
2022-09-25 13:45:19 +04:00
wheelsCount = WheelsCount.Four;
break;
}
2022-09-27 16:26:05 +04:00
default:
break;
2022-09-25 13:45:19 +04:00
}
}
2022-09-27 16:26:05 +04:00
private Color color;
public void SetColor(Color color) {
this.color = color;
}
2022-09-25 13:45:19 +04:00
public ExtraWheelsDraw(int num, Color color) {
setExtraNum(num);
2022-09-25 13:45:19 +04:00
this.color = color;
}
public String TypeString() {
return "Simple";
}
public int getWheelsCount() {
if (wheelsCount == WheelsCount.Two) return 2;
if (wheelsCount == WheelsCount.Three) return 3;
else return 4;
}
public void DrawExtra(int startPosX, int startPosY, Graphics2D g) {
2022-10-08 23:13:09 +04:00
g.setColor(Color.BLACK);
g.drawOval(startPosX, startPosY + 30, 20, 20);
g.drawOval(startPosX + 90, startPosY + 30, 20, 20);
g.setColor(Color.BLACK);
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX, startPosY + 30, 20, 20);
g.fillOval(startPosX + 90, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
switch (wheelsCount) {
2022-09-27 16:26:05 +04:00
case Four: {
2022-10-08 23:13:09 +04:00
g.setColor(color);
g.drawOval(startPosX + 70, startPosY + 30, 20, 20);
g.setColor(Color.BLACK);
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX + 70, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
}
case Three: {
2022-10-08 23:13:09 +04:00
g.fillOval(startPosX + 20, startPosY + 30, 20, 20);
g.setColor(color);
2022-10-08 23:13:09 +04:00
g.drawOval(startPosX + 20, startPosY + 30, 20, 20);
2022-09-25 13:45:19 +04:00
break;
}
2022-09-27 16:26:05 +04:00
default:
break;
2022-09-25 13:45:19 +04:00
}
}
2022-09-27 16:26:05 +04:00
2022-09-25 13:45:19 +04:00
}