Финал

This commit is contained in:
DyCTaTOR 2023-12-06 10:09:34 +04:00
parent 8737449c24
commit 8be5839af0
2 changed files with 8 additions and 14 deletions

View File

@ -1,8 +1,6 @@
import java.awt.Color;
import java.awt.Graphics;
public class DrawingWheels{
private int _startPosX;
private int _startPosY;
Graphics g;
Color color;
private CountWheels _countWheels;
@ -16,14 +14,11 @@ public class DrawingWheels{
_countWheels = CountWheels.fromNumberToEnum(numRollers);
}
public DrawingWheels(Graphics g, int startPosX, int startPosY, Color color, int countWheels){
this.g = g;
_startPosX = startPosX;
_startPosY = startPosY;
public DrawingWheels(Color color, int countWheels){
this.color = color;
setNumWheels(countWheels);
}
public void Draw(){
public void Draw(Graphics g, int _startPosX, int _startPosY){
switch(_countWheels){
case Min:
g.setColor(Color.BLACK);

View File

@ -13,7 +13,7 @@ public class DrawningMonorail extends JPanel {
private int relWidth = 150;
private final int relHeight = 46;
Random rd = new Random();
public DrawningMonorail(){}
private DrawingWheels _drawingWheels;
public boolean init(int wheelCount ,int speed, double weight, Color bodyColor, Color additionalColor,
boolean monorails, boolean secondCabin, int width, int height) {
@ -25,6 +25,7 @@ public class DrawningMonorail extends JPanel {
pictureHeight = height;
entity = new Entity();
entity.init(wheelCount, speed, weight, bodyColor, additionalColor, monorails, secondCabin);
_drawingWheels = new DrawingWheels(entity.getBodyColor(), _countWheels);
return true;
}
@ -77,9 +78,7 @@ public class DrawningMonorail extends JPanel {
g.fillRect(_startPosX + 82, _startPosY + 36, 40, 8);
g.fillOval( _startPosX + 3, _startPosY + 37, 30, 8);
g.fillOval( _startPosX + 110, _startPosY + 37, 29, 8);
DrawingWheels _drawingWheels = new DrawingWheels(g, _startPosX, _startPosY,
entity.getBodyColor(), _countWheels);
_drawingWheels.Draw();
_drawingWheels.Draw(g, _startPosX, _startPosY);
//Кабина
g.setColor(entity.getBodyColor());
@ -139,9 +138,9 @@ public class DrawningMonorail extends JPanel {
g.fillOval(_startPosX + 143, _startPosY + 37, 30, 8);
g.fillOval(_startPosX + 250, _startPosY + 37, 29, 8);
_drawingWheels = new DrawingWheels(g, _startPosX + 140, _startPosY,
entity.getAdditionalColor(), _countWheels);
_drawingWheels.Draw();
//_drawingWheels = new DrawingWheels(g, _startPosX + 140, _startPosY,
//entity.getAdditionalColor(), _countWheels);
_drawingWheels.Draw(g, _startPosX + 140, _startPosY);
if (entity.getMonorails())
{
g.setColor(Color.BLACK);