2023-10-09 21:18:09 +04:00
package laba1Loco ;
import java.awt.* ;
import java.util.* ;
import javax.swing.* ;
import javax.swing.Timer ;
import java.awt.event.* ;
public class WheelDrawingDavidStar 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 . WHITE ) ;
g2d . drawPolygon ( new int [ ] {
_startPosX + 1 , _startPosX + 7 , _startPosX + 3
} , new int [ ] {
_startPosY + 2 , _startPosY + 2 , _startPosY + 7
} , 3 ) ;
g2d . drawPolygon ( new int [ ] {
_startPosX + 1 , _startPosX + 7 , _startPosX + 4
} , new int [ ] {
_startPosY + 6 , _startPosY + 6 , _startPosY + 1
} , 3 ) ;
}
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 ) ;
2023-11-05 01:52:42 +04:00
if ( numWheel = = NumWheel . ThreeWheel ) {
2023-10-09 21:18:09 +04:00
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 ) ;
2023-11-05 01:52:42 +04:00
if ( numWheel = = NumWheel . ThreeWheel ) {
2023-10-09 21:18:09 +04:00
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 ) ;
}
}
}
}