PIbd-21_Kouvshinoff_T._A._W.../laba1Loco/WheelDrawingBalls.java
2023-11-05 01:52:42 +04:00

81 lines
3.3 KiB
Java

package laba1Loco;
import java.awt.*;
import java.util.*;
import javax.swing.*;
import javax.swing.Timer;
import java.awt.event.*;
public class WheelDrawingBalls implements IWheelDrawing{
private NumWheel numWheel;
public NumWheel getNumWheel() {
return numWheel;
}
public void setNumWheel(int kwheel){
switch(kwheel){
case 2:
numWheel = NumWheel.TwoWheel;
break;
case 3:
numWheel = NumWheel.ThreeWheel;
break;
case 4:
numWheel = NumWheel.FourWheel;
break;
default:
numWheel = NumWheel.TwoWheel;
System.out.println("ВСё плохо, колво колёс почему то не соответтвовало критериям, количество колёс:" + Integer.toString(kwheel) + "но вывели мы как будто их было 2");
break;
}
}
private void DrawWheel(int _startPosX, int _startPosY, Color color, Graphics2D g2d){
g2d.setColor(color);
g2d.fillOval(_startPosX, _startPosY, 8, 8);
g2d.setColor(Color.PINK);
g2d.fillOval( _startPosX+3, _startPosY+1, 2, 3);
g2d.fillOval( _startPosX+1, _startPosY+4, 2, 2);
g2d.fillOval( _startPosX+6, _startPosY+4, 2, 2);
}
public void Draw(int _startPosX, int _startPosY, boolean fuelTank, Color color, Graphics2D g2d){
DrawWheel(_startPosX + 3, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 26, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 46, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 72, _startPosY + 34, color, g2d);
if (numWheel == NumWheel.ThreeWheel){
DrawWheel(_startPosX + 14, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 59, _startPosY + 34, color, g2d);
}
if (numWheel == NumWheel.FourWheel){
DrawWheel(_startPosX + 11, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 18, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 55, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 63, _startPosY + 34, color, g2d);
}
if (fuelTank){
DrawWheel(_startPosX + 3+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 26+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 46+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 72+85, _startPosY + 34, color, g2d);
if (numWheel == NumWheel.ThreeWheel){
DrawWheel(_startPosX + 14+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 59+85, _startPosY + 34, color, g2d);
}
if (numWheel == NumWheel.FourWheel){
DrawWheel(_startPosX + 11+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 18+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 55+85, _startPosY + 34, color, g2d);
DrawWheel(_startPosX + 63+85, _startPosY + 34, color, g2d);
}
}
}
}