PIbd-21_KozyrevSS_GasolineT.../DrawWheelSquare.java

43 lines
1.6 KiB
Java

import java.awt.*;
import java.util.Random;
public class DrawWheelSquare implements IWheelDraw{
private WheelCounter wheelCounter;
public WheelCounter getWheelCounter()
{
return wheelCounter;
}
public void setWheelCount(int count)
{
if (count % 3 == 0)
wheelCounter = WheelCounter.THREE;
else if (count % 3 == 1)
wheelCounter = WheelCounter.FOUR;
else if (count % 3 == 2)
wheelCounter = WheelCounter.TWO;
}
public void DrawWheels(int _startPosX, int _startPosY, Color bodyColor, Graphics2D g2d)
{
g2d.setColor(bodyColor);
g2d.fillOval(10 + _startPosX, 60 + _startPosY, 20, 20);
g2d.drawString("S",15 + _startPosX, 60 + _startPosY);
g2d.fillOval(80 + _startPosX, 60 + _startPosY, 20, 20);
switch (wheelCounter)
{
case THREE -> {g2d.fillOval(45 + _startPosX, 60 + _startPosY ,20, 20);}
case FOUR -> {g2d.fillOval(30 + _startPosX, 60 + _startPosY ,20, 20); g2d.fillOval(60 + _startPosX, 60 + _startPosY ,20, 20);}
}
Random rnd = new Random();
Color stringColor = new Color(rnd.nextInt(0, 256), rnd.nextInt(0, 256), rnd.nextInt(0, 256));
g2d.setColor(stringColor);
g2d.fillRect(15 + _startPosX, 65 + _startPosY, 10, 10);
g2d.fillRect(85 + _startPosX, 65 + _startPosY, 10, 10);
switch (wheelCounter)
{
case THREE -> {g2d.fillRect(50 + _startPosX, 65 + _startPosY, 10, 10);}
case FOUR -> {g2d.fillRect(35 + _startPosX, 65 + _startPosY, 10, 10); g2d.fillRect(65 + _startPosX, 65 + _startPosY, 10, 10);}
}
}
}