PIbd-22_Chernyshev_G.J._29_.../Trolleybus/DrawingDoors.java

56 lines
2.3 KiB
Java
Raw Permalink Normal View History

2023-11-11 21:48:58 +04:00
package Trolleybus;
import java.awt.*;
2023-11-13 22:25:33 +04:00
public class DrawingDoors implements IDrawingDoors{
2023-11-11 21:48:58 +04:00
private CntOfDoors _cntOfDoors;
public void SetCntOfDoors(int cnt) {
if (cnt <= 3) {
_cntOfDoors = CntOfDoors.Three;
2023-11-11 21:48:58 +04:00
}
if (cnt == 4) {
_cntOfDoors = CntOfDoors.Four;
}
if (cnt >= 5) {
_cntOfDoors = CntOfDoors.Five;
2023-11-11 21:48:58 +04:00
}
}
public void DrawDoors(Graphics2D g, Color BodyColor, int _startPosX, int _startPosY) {
switch (_cntOfDoors)
2023-11-11 21:48:58 +04:00
{
case Three:
2023-11-11 21:48:58 +04:00
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:
2023-11-11 21:48:58 +04:00
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:
2023-11-11 21:48:58 +04:00
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;
}
}
}