PIbd-22_Chernyshev_G.J._29_.../Trolleybus/DrawingDoors.java
2023-11-13 21:25:33 +03:00

56 lines
2.3 KiB
Java

package Trolleybus;
import java.awt.*;
public class DrawingDoors implements IDrawingDoors{
private CntOfDoors _cntOfDoors;
public void SetCntOfDoors(int cnt) {
if (cnt <= 3) {
_cntOfDoors = CntOfDoors.Three;
}
if (cnt == 4) {
_cntOfDoors = CntOfDoors.Four;
}
if (cnt >= 5) {
_cntOfDoors = CntOfDoors.Five;
}
}
public void DrawDoors(Graphics2D g, Color BodyColor, int _startPosX, int _startPosY) {
switch (_cntOfDoors)
{
case Three:
g.setColor(BodyColor);
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
g.setColor(Color.CYAN);
g.drawOval(_startPosX + 22, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 47, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 87, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 112, _startPosY + 35, 16, 24);
break;
case Four:
g.setColor(BodyColor);
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 86, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
g.setColor(Color.CYAN);
g.drawOval(_startPosX + 25, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 67, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
break;
case Five:
g.setColor(BodyColor);
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 86, _startPosY + 50, 16, 30);
g.drawRect(_startPosX + 132, _startPosY + 50, 16, 30);
g.setColor(Color.CYAN);
g.drawOval(_startPosX + 25, _startPosY + 35, 16, 24);
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
break;
}
}
}