PIbd-23_Panina_A.D.Cruiser..../DopClassMixed.java

34 lines
1.1 KiB
Java
Raw Normal View History

2023-12-09 00:17:07 +04:00
import java.awt.*;
public class DopClassMixed implements IDop{
public int numOfWheels;
public DopClassMixed(int num){
numOfWheels = num;
}
public void setNumOfWheels(String num){
switch (Integer.valueOf(num)){
case 2:
numOfWheels = NumberOfWheelsEnum.wheel_2.value;
break;
case 3:
numOfWheels = NumberOfWheelsEnum.wheel_3.value;
break;
case 4:
numOfWheels = NumberOfWheelsEnum.wheel_4.value;
break;
default:
numOfWheels = NumberOfWheelsEnum.wheel_2.value;
}
}
public void drawWheels(Graphics g, int _startPosX, int _startPosY, Color c) {
g.setColor(c);
if (numOfWheels >= 2) {
g.fillRect(_startPosX+55, _startPosY+20, 20, 15);
g.fillRect(_startPosX+55, _startPosY+40, 20, 15);
} if (numOfWheels >= 3) {
g.fillOval(_startPosX+30, _startPosY+20, 20, 15);
} if (numOfWheels >= 4) {
g.fillRect(_startPosX+85, _startPosY+20, 20, 15);
}
}
}