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

65 lines
1.8 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 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) {
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;
}
}
}