Частично изменил с перечислением
This commit is contained in:
parent
31cdee9b88
commit
f681dfddc4
@ -1,14 +1,7 @@
|
|||||||
package Trolleybus;
|
package Trolleybus;
|
||||||
|
|
||||||
public enum CntOfDoors {
|
public enum CntOfDoors {
|
||||||
Three (3),
|
Three,
|
||||||
Four (4),
|
Four,
|
||||||
Five (5);
|
Five
|
||||||
private int Cnt;
|
|
||||||
CntOfDoors(int cnt) {
|
|
||||||
Cnt = cnt;
|
|
||||||
}
|
|
||||||
public int getCnt(){
|
|
||||||
return Cnt;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -4,22 +4,21 @@ import java.awt.*;
|
|||||||
public class DrawingDoors {
|
public class DrawingDoors {
|
||||||
private CntOfDoors _cntOfDoors;
|
private CntOfDoors _cntOfDoors;
|
||||||
public void SetCntOfDoors(int cnt) {
|
public void SetCntOfDoors(int cnt) {
|
||||||
if (cnt < 3 || cnt > 5) {
|
if (cnt <= 3) {
|
||||||
cnt = 3;
|
_cntOfDoors = CntOfDoors.Three;
|
||||||
}
|
}
|
||||||
//Проход по перечислению
|
if (cnt == 4) {
|
||||||
for (CntOfDoors temp : CntOfDoors.values()) {
|
_cntOfDoors = CntOfDoors.Four;
|
||||||
if (temp.getCnt() == cnt) {
|
|
||||||
_cntOfDoors = temp;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
if (cnt >= 5) {
|
||||||
|
_cntOfDoors = CntOfDoors.Five;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawDoors(Graphics2D g, Color BodyColor, int _startPosX, int _startPosY) {
|
public void DrawDoors(Graphics2D g, Color BodyColor, int _startPosX, int _startPosY) {
|
||||||
switch (_cntOfDoors.getCnt())
|
switch (_cntOfDoors)
|
||||||
{
|
{
|
||||||
case 3:
|
case Three:
|
||||||
g.setColor(BodyColor);
|
g.setColor(BodyColor);
|
||||||
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||||||
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 67, _startPosY + 50, 16, 30);
|
||||||
@ -30,7 +29,7 @@ public class DrawingDoors {
|
|||||||
g.drawOval(_startPosX + 87, _startPosY + 35, 16, 24);
|
g.drawOval(_startPosX + 87, _startPosY + 35, 16, 24);
|
||||||
g.drawOval(_startPosX + 112, _startPosY + 35, 16, 24);
|
g.drawOval(_startPosX + 112, _startPosY + 35, 16, 24);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case Four:
|
||||||
g.setColor(BodyColor);
|
g.setColor(BodyColor);
|
||||||
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||||||
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
||||||
@ -41,7 +40,7 @@ public class DrawingDoors {
|
|||||||
g.drawOval(_startPosX + 67, _startPosY + 35, 16, 24);
|
g.drawOval(_startPosX + 67, _startPosY + 35, 16, 24);
|
||||||
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
|
g.drawOval(_startPosX + 109, _startPosY + 35, 16, 24);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case Five:
|
||||||
g.setColor(BodyColor);
|
g.setColor(BodyColor);
|
||||||
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 2, _startPosY + 50, 16, 30);
|
||||||
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
g.drawRect(_startPosX + 48, _startPosY + 50, 16, 30);
|
||||||
|
Loading…
Reference in New Issue
Block a user