diff --git a/src/AbstractStrategy.java b/src/AbstractStrategy.java new file mode 100644 index 0000000..3c4326f --- /dev/null +++ b/src/AbstractStrategy.java @@ -0,0 +1,82 @@ +public abstract class AbstractStrategy { + private IMoveableObject _moveableObject; + private Status _state = Status.NotInit; + protected int FieldWidth; + protected int FieldHeight; + public Status GetStatus() { return _state; } + + public void SetData(IMoveableObject moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = Status.NotInit; + return; + } + _state = Status.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + public void MakeStep() + { + if (_state != Status.InProgress) + { + return; + } + if (IsTargetDestinaion()) + { + _state = Status.Finish; + return; + } + MoveToTarget(); + } + + protected boolean MoveLeft(){ + return MoveTo(DyrectionType.Left); + } + + protected boolean MoveRight(){ + return MoveTo(DyrectionType.Right); + } + + protected boolean MoveUp(){ + return MoveTo(DyrectionType.Up); + } + + protected boolean MoveDown(){ + return MoveTo(DyrectionType.Down); + } + + /// Параметры объекта + protected ObjectParameters GetObjectParameters(){ + if(_moveableObject == null) return null; + return _moveableObject.GetObjectPosition(); + } + + protected int GetStep() + { + if (_state != Status.InProgress) + { + return -1; + } + if(_moveableObject == null) return -1; + return _moveableObject.GetStep(); + } + protected abstract void MoveToTarget(); + + protected abstract boolean IsTargetDestinaion(); + + private boolean MoveTo(DyrectionType directionType) + { + if (_state != Status.InProgress) + { + return false; + } + if (_moveableObject.CheckCanMove(directionType) == false) return false; + { + _moveableObject.MoveObject(directionType); + return true; + } + } +} diff --git a/src/DrawingEmptyWheels.java b/src/DrawingEmptyWheels.java new file mode 100644 index 0000000..427452d --- /dev/null +++ b/src/DrawingEmptyWheels.java @@ -0,0 +1,26 @@ +import java.awt.*; + +public class DrawingEmptyWheels implements IDrawingWheels{ + private WheelsCount _wheelsCount; + @Override + public void SetWheelsCount(int wheelsCount) { + for (WheelsCount val : WheelsCount.values()) { + if (val.count == wheelsCount) { + _wheelsCount = val; + return; + } + } + this._wheelsCount = WheelsCount.Five; + } + + @Override + public WheelsCount GetWheelsCount() { + return _wheelsCount; + } + + @Override + public void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) { + g2d.setColor(Color.BLACK); + g2d.drawOval(x, y, w, h); + } +} diff --git a/src/DrawingObjectUsta.java b/src/DrawingObjectUsta.java new file mode 100644 index 0000000..11cb34a --- /dev/null +++ b/src/DrawingObjectUsta.java @@ -0,0 +1,28 @@ +public class DrawingObjectUsta implements IMoveableObject { + private DrawingUsta _drawningUsta = null; + public DrawingObjectUsta(DrawingUsta drawningUsta) + { + _drawningUsta = drawningUsta; + } + public ObjectParameters GetObjectPosition() + { + if (_drawningUsta == null || _drawningUsta.EntityUsta == null) + { + return null; + } + return new ObjectParameters(_drawningUsta.GetPosX(), _drawningUsta.GetPosY(), + _drawningUsta.GetWidth(), _drawningUsta.GetHeight()); + } + public int GetStep(){ + if(_drawningUsta == null) return -1; + return (int)(_drawningUsta.EntityUsta.Step()); + } + public boolean CheckCanMove(DyrectionType direction){ + if(_drawningUsta == null) return false; + return _drawningUsta.CanMove(direction); + } + public void MoveObject(DyrectionType direction){ + if(_drawningUsta == null) return; + _drawningUsta.MoveTransport(direction); + } +} diff --git a/src/DrawingUsta.java b/src/DrawingUsta.java index 1d90345..2c279fd 100644 --- a/src/DrawingUsta.java +++ b/src/DrawingUsta.java @@ -1,37 +1,68 @@ import java.awt.*; import java.awt.geom.Path2D; import java.awt.geom.Arc2D; +import java.util.Random; + public class DrawingUsta { public EntityUsta EntityUsta; - private DrawingWheel _drawingWheel; + protected IDrawingWheels _drawingWheels; private int _pictureWidth; private int _pictureHeight; - private int _startPosX; - private int _startPosY; - private final int _ustaWidth = 170; - private final int _ustaHeight = 90; + public int _startPosX; + public int _startPosY; + private int _ustaWidth = 170; + private int _ustaHeight = 90; - public boolean Init(int speed, double weight, Color bodyColor, Color additionalColor, - boolean bodyKit, boolean pushka, int width, int height) + public int GetPosX(){ + return _startPosX; + } + public int GetPosY(){ + return _startPosY; + } + public int GetWidth(){ + return _ustaWidth; + } + public int GetHeight(){ + return _ustaHeight; + } + + public DrawingUsta(int speed, double weight, Color bodyColor, int width, int height) { - if (width < _ustaWidth || height < _ustaHeight) { - return false; + return; } _pictureWidth = width; _pictureHeight = height; - EntityUsta = new EntityUsta(); - _drawingWheel = new DrawingWheel(); - EntityUsta.Init(speed, weight, bodyColor, additionalColor, bodyKit, pushka); - return true; + EntityUsta = new EntityUsta(speed, weight, bodyColor); + + Random rnd = new Random(); + int WhatWheels = rnd.nextInt(0, 3); + + if(WhatWheels == 0) _drawingWheels = new DrawingWheel(); + if(WhatWheels == 1) _drawingWheels = new DrawingEmptyWheels(); + if(WhatWheels == 2) _drawingWheels = new DrawingWheelsBlueCrom(); } - public void SetWheelsCount(int weelsCount) { - - _drawingWheel.SetWheelsCount(weelsCount); + public void SetWheelsCount(int wheelsCount){ + _drawingWheels.SetWheelsCount(wheelsCount); } + protected DrawingUsta(int speed, double weight, Color bodyColor, int width, + int height, int ustaWidth, int ustaHeight) + { + this(speed,weight, bodyColor, width, height); + if (width < _ustaWidth || height < _ustaHeight) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + _ustaWidth = ustaWidth; + _ustaHeight = ustaHeight; + } + + public void SetPosition(int x, int y) { if (x < 0 || x + _ustaWidth > _pictureWidth) @@ -72,11 +103,7 @@ public class DrawingUsta { if (EntityUsta == null) { return; } - - - Color bodyColor = EntityUsta.BodyColor; - Color additionalColor = EntityUsta.AdditionalColor; Color blackBrush = Color.BLACK; @@ -85,146 +112,56 @@ public class DrawingUsta { int cornerRadius1 = 12; - _drawingWheel.DrawWheels(g, additionalColor, _startPosX, _startPosY); + Path2D path = new Path2D.Double(); - g.setColor(color1); + path.append(new Arc2D.Double(_startPosX + 5, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(_startPosX + 140, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(_startPosX + 140, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); + + path.append(new Arc2D.Double(_startPosX + 5, _startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); + path.closePath(); + g.setColor(bodyColor); + g.fill(path); + g.setColor(Color.BLACK); + g.draw(path); + + _drawingWheels.DrawWheels(g, blackBrush, _startPosX, _startPosY, 9,9); + + g.setColor(bodyColor); g.fillRect(_startPosX + 45, _startPosY + 20, 40, 20); g.setColor(Color.BLACK); g.drawRect(_startPosX + 45, _startPosY + 20, 40, 20); - - - g.setColor(color1); - + g.setColor(bodyColor); g.fillRect(_startPosX + 10, _startPosY + 40, 120, 10); - g.setColor(Color.BLACK); g.drawRect(_startPosX + 10, _startPosY + 40, 120, 10); - if(EntityUsta.BodyKit) - { - Path2D path1 = new Path2D.Double(); - path1.moveTo(_startPosX + 15, _startPosY + 40); - path1.lineTo(_startPosX + 15, _startPosY + 30); - path1.lineTo(_startPosX + 15, _startPosY + 35); - path1.lineTo(_startPosX + 25, _startPosY + 35); - path1.lineTo(_startPosX + 30, _startPosY + 30); - path1.lineTo(_startPosX + 35, _startPosY + 40); - path1.closePath(); - - g.setColor(Color.BLACK); - - g.draw(path1); - - g.setColor(color2); - g.fill(path1); - - Path2D path2 = new Path2D.Double(); - path2.moveTo(_startPosX + 15, _startPosY + 30); - path2.lineTo(_startPosX + 40, _startPosY + 20); - path2.lineTo(_startPosX + 40, _startPosY + 25); - path2.lineTo(_startPosX + 25, _startPosY + 35); - path2.closePath(); - - g.setColor(Color.BLACK); - g.draw(path2); - - g.setColor(additionalColor); - g.fill(path2); - - Path2D path3 = new Path2D.Double(); - path3.moveTo(_startPosX + 10, _startPosY + 32); - path3.lineTo(_startPosX, _startPosY + 10); - path3.lineTo(_startPosX + 40, _startPosY - 7); - path3.lineTo(_startPosX + 50, _startPosY + 16); - path3.closePath(); - - g.setColor(Color.BLACK); - g.draw(path3); - - g.setColor(bodyColor); - g.fill(path3); - - Path2D path4 = new Path2D.Double(); - path4.moveTo(_startPosX, _startPosY + 10); - path4.lineTo(_startPosX + 40, _startPosY - 7); - path4.lineTo(_startPosX + 43, _startPosY - 5); - path4.lineTo(_startPosX + 41, _startPosY - 3); - path4.lineTo(_startPosX + 2, _startPosY + 13); - path4.closePath(); - - g.setColor(Color.BLACK); - - g.draw(path4); - - g.setColor(additionalColor); - g.fill(path4); - - Path2D path5 = new Path2D.Double(); - path5.moveTo(_startPosX + 3, _startPosY + 15); - path5.lineTo(_startPosX + 45, _startPosY - 2); - path5.lineTo(_startPosX + 46, _startPosY - 2); - path5.lineTo(_startPosX + 49, _startPosY - 1); - path5.lineTo(_startPosX + 46, _startPosY + 3); - path5.lineTo(_startPosX + 6, _startPosY + 20); - path5.closePath(); - - g.setColor(Color.BLACK); - - g.draw(path5); - - g.setColor(bodyColor); - g.fill(path5); - - Path2D path6 = new Path2D.Double(); - path6.moveTo(_startPosX + 5, _startPosY + 22); - path6.lineTo(_startPosX + 47, _startPosY + 5); - path6.lineTo(_startPosX + 51, _startPosY + 5); - path6.lineTo(_startPosX + 53, _startPosY + 7); - path6.lineTo(_startPosX + 8, _startPosY + 25); - path6.closePath(); - - g.setColor(Color.BLACK); - - g.draw(path6); - - g.setColor(additionalColor); - g.fill(path6); - - Path2D path7 = new Path2D.Double(); - path7.moveTo(_startPosX + 7, _startPosY + 27); - path7.lineTo(_startPosX + 46, _startPosY + 11); - path7.lineTo(_startPosX + 51, _startPosY + 9); - path7.lineTo(_startPosX + 56, _startPosY + 11); - path7.lineTo(_startPosX + 10, _startPosY + 31); - path7.closePath(); - - g.setColor(Color.BLACK); - - g.draw(path7); - - g.setColor(bodyColor); - g.fill(path7); - } - - - - if(EntityUsta.Pushka) - { - g.fillRect(_startPosX + 80, _startPosY + 25, 10, 10); - - g.setColor(Color.BLACK); - g.drawRect(_startPosX + 80, _startPosY + 25, 10, 10); - g.setColor(color1); - g.fillRect(_startPosX + 90, _startPosY + 28, 40, 5); - - g.setColor(Color.BLACK); - g.drawRect(_startPosX + 90, _startPosY + 28, 40, 5); - g.setColor(additionalColor); - g.fillRect(_startPosX + 130, _startPosY + 27, 5, 7); - - g.setColor(Color.BLACK); - g.drawRect(_startPosX + 130, _startPosY + 27, 5, 7); - } } + + public boolean CanMove(DyrectionType direction) + { + if (EntityUsta == null) + { + return false; + } + switch(direction) { + //влево + case Left: + if (_startPosX - EntityUsta.Step() > 0) return true; + break; + case Up: + if (_startPosY - EntityUsta.Step() > 0) return true; + break; + case Right: + if (_startPosX + EntityUsta.Step() < _pictureWidth) return true; + break; + case Down: + if (_startPosY + EntityUsta.Step() < _pictureHeight) return true; + break; + } + return false; + } } diff --git a/src/DrawingUstaBat.java b/src/DrawingUstaBat.java new file mode 100644 index 0000000..d29a735 --- /dev/null +++ b/src/DrawingUstaBat.java @@ -0,0 +1,157 @@ +import java.awt.*; +import java.awt.geom.Path2D; + +public class DrawingUstaBat extends DrawingUsta { + public DrawingUstaBat(int speed, double weight, Color bodyColor, Color additionalColor, + boolean pushka, boolean bodyKit, int width, int height) + { + super(speed, weight, bodyColor, width, height, 170, 90); + if (EntityUsta != null) + { + EntityUsta = new EntityUstaBat(speed, width, bodyColor, additionalColor, pushka, bodyKit); + } + } + @Override + public void DrawTransport(Graphics2D g) + { + if (EntityUsta instanceof EntityUstaBat ustabat) ///////// WARNING INSTANCEOF + { + Color bodyColor = EntityUsta.BodyColor; + Color additionalColor = ustabat.AdditionalColor; + + Color blackBrush = Color.BLACK; + + Color color1 = new Color(65, 72, 51); + Color color2 = new Color(47, 69, 56); + + if(ustabat.BodyKit) + { + Path2D path1 = new Path2D.Double(); + path1.moveTo(_startPosX + 15, _startPosY + 40); + path1.lineTo(_startPosX + 15, _startPosY + 30); + path1.lineTo(_startPosX + 15, _startPosY + 35); + path1.lineTo(_startPosX + 25, _startPosY + 35); + path1.lineTo(_startPosX + 30, _startPosY + 30); + path1.lineTo(_startPosX + 35, _startPosY + 40); + path1.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path1); + + g.setColor(color2); + g.fill(path1); + + Path2D path2 = new Path2D.Double(); + path2.moveTo(_startPosX + 15, _startPosY + 30); + path2.lineTo(_startPosX + 40, _startPosY + 20); + path2.lineTo(_startPosX + 40, _startPosY + 25); + path2.lineTo(_startPosX + 25, _startPosY + 35); + path2.closePath(); + + g.setColor(Color.BLACK); + g.draw(path2); + + g.setColor(additionalColor); + g.fill(path2); + + Path2D path3 = new Path2D.Double(); + path3.moveTo(_startPosX + 10, _startPosY + 32); + path3.lineTo(_startPosX, _startPosY + 10); + path3.lineTo(_startPosX + 40, _startPosY - 7); + path3.lineTo(_startPosX + 50, _startPosY + 16); + path3.closePath(); + + g.setColor(Color.BLACK); + g.draw(path3); + + g.setColor(bodyColor); + g.fill(path3); + + Path2D path4 = new Path2D.Double(); + path4.moveTo(_startPosX, _startPosY + 10); + path4.lineTo(_startPosX + 40, _startPosY - 7); + path4.lineTo(_startPosX + 43, _startPosY - 5); + path4.lineTo(_startPosX + 41, _startPosY - 3); + path4.lineTo(_startPosX + 2, _startPosY + 13); + path4.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path4); + + g.setColor(additionalColor); + g.fill(path4); + + Path2D path5 = new Path2D.Double(); + path5.moveTo(_startPosX + 3, _startPosY + 15); + path5.lineTo(_startPosX + 45, _startPosY - 2); + path5.lineTo(_startPosX + 46, _startPosY - 2); + path5.lineTo(_startPosX + 49, _startPosY - 1); + path5.lineTo(_startPosX + 46, _startPosY + 3); + path5.lineTo(_startPosX + 6, _startPosY + 20); + path5.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path5); + + g.setColor(bodyColor); + g.fill(path5); + + Path2D path6 = new Path2D.Double(); + path6.moveTo(_startPosX + 5, _startPosY + 22); + path6.lineTo(_startPosX + 47, _startPosY + 5); + path6.lineTo(_startPosX + 51, _startPosY + 5); + path6.lineTo(_startPosX + 53, _startPosY + 7); + path6.lineTo(_startPosX + 8, _startPosY + 25); + path6.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path6); + + g.setColor(additionalColor); + g.fill(path6); + + Path2D path7 = new Path2D.Double(); + path7.moveTo(_startPosX + 7, _startPosY + 27); + path7.lineTo(_startPosX + 46, _startPosY + 11); + path7.lineTo(_startPosX + 51, _startPosY + 9); + path7.lineTo(_startPosX + 56, _startPosY + 11); + path7.lineTo(_startPosX + 10, _startPosY + 31); + path7.closePath(); + + g.setColor(Color.BLACK); + + g.draw(path7); + + g.setColor(bodyColor); + g.fill(path7); + } + + + + + + if(ustabat.Pushka) + { + g.fillRect(_startPosX + 80, _startPosY + 25, 10, 10); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 80, _startPosY + 25, 10, 10); + g.setColor(color1); + g.fillRect(_startPosX + 90, _startPosY + 28, 40, 5); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 90, _startPosY + 28, 40, 5); + g.setColor(additionalColor); + g.fillRect(_startPosX + 130, _startPosY + 27, 5, 7); + + g.setColor(Color.BLACK); + g.drawRect(_startPosX + 130, _startPosY + 27, 5, 7); + } + super.DrawTransport(g); + } + } +} diff --git a/src/DrawingWheel.java b/src/DrawingWheel.java index d76ff04..6ec2a06 100644 --- a/src/DrawingWheel.java +++ b/src/DrawingWheel.java @@ -2,7 +2,7 @@ import java.awt.*; import java.awt.geom.Arc2D; import java.awt.geom.Path2D; -public class DrawingWheel { +public class DrawingWheel implements IDrawingWheels { private WheelsCount _wheelsCount; public void SetWheelsCount(int enginesCount) { for (WheelsCount val : WheelsCount.values()) { @@ -11,130 +11,16 @@ public class DrawingWheel { return; } } + this._wheelsCount = WheelsCount.Five; } - public void DrawWheels(Graphics2D g, Color color, int startPosX, int startPosY) { - if (_wheelsCount == null) { - return; - } + @Override + public WheelsCount GetWheelsCount() { + return _wheelsCount; + } - int cornerRadius1 = 12; - Color color1 = new Color(65, 72, 51); - - if (_wheelsCount.count >= _wheelsCount.Four.count) { - - Path2D path = new Path2D.Double(); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 110, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 110, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); - path.closePath(); - - g.setColor(color1); - - g.fill(path); - g.setColor(Color.BLACK); - g.draw(path); - - - /* наверху гусеницы*/ - g.fillOval(startPosX + 47, startPosY + 44, 13, 13); - g.fillOval(startPosX + 62, startPosY + 44, 13, 13); - g.fillOval(startPosX + 77, startPosY + 44, 13, 13); - - /* по середине гусеницы*/ - g.drawOval(startPosX + 40, startPosY + 59, 13, 13); - g.drawOval(startPosX + 55, startPosY + 59, 13, 13); - g.drawOval(startPosX + 70, startPosY + 59, 13, 13); - g.drawOval(startPosX + 85, startPosY + 59, 13, 13); - - - /* два крайних на гусенице*/ - g.fillOval(startPosX + 10, startPosY + 50, 25, 25); - g.fillOval(startPosX + 105, startPosY + 50, 25, 25); - - } - - if (_wheelsCount.count >= _wheelsCount.Five.count) { - Path2D path = new Path2D.Double(); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 125, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 125, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); - path.closePath(); - - g.setColor(color1); - - g.fill(path); - g.setColor(Color.BLACK); - g.draw(path); - - - /* наверху гусеницы*/ - g.fillOval(startPosX + 47, startPosY + 44, 13, 13); - g.fillOval(startPosX + 62, startPosY + 44, 13, 13); - g.fillOval(startPosX + 77, startPosY + 44, 13, 13); - g.fillOval(startPosX + 92, startPosY + 44, 13, 13); - - /* по середине гусеницы*/ - g.drawOval(startPosX + 40, startPosY + 59, 13, 13); - g.drawOval(startPosX + 55, startPosY + 59, 13, 13); - g.drawOval(startPosX + 70, startPosY + 59, 13, 13); - g.drawOval(startPosX + 85, startPosY + 59, 13, 13); - g.drawOval(startPosX + 100, startPosY + 59, 13, 13); - - - /* два крайних на гусенице*/ - g.fillOval(startPosX + 10, startPosY + 50, 25, 25); - g.fillOval(startPosX + 120, startPosY + 50, 25, 25); - } - - if (_wheelsCount.count >= _wheelsCount.Six.count) { - Path2D path = new Path2D.Double(); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 180, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 140, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 270, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 140, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 0, 90, Arc2D.OPEN), true); - - path.append(new Arc2D.Double(startPosX + 5, startPosY + 50, 2 * cornerRadius1, 2 * cornerRadius1, 90, 90, Arc2D.OPEN), true); - path.closePath(); - - g.setColor(color1); - - g.fill(path); - g.setColor(Color.BLACK); - g.draw(path); - - - /* наверху гусеницы*/ - g.fillOval(startPosX + 47, startPosY + 44, 13, 13); - g.fillOval(startPosX + 62, startPosY + 44, 13, 13); - g.fillOval(startPosX + 77, startPosY + 44, 13, 13); - g.fillOval(startPosX + 92, startPosY + 44, 13, 13); - g.fillOval(startPosX + 107, startPosY + 44, 13, 13); - - /* по середине гусеницы*/ - g.drawOval(startPosX + 40, startPosY + 59, 13, 13); - g.drawOval(startPosX + 55, startPosY + 59, 13, 13); - g.drawOval(startPosX + 70, startPosY + 59, 13, 13); - g.drawOval(startPosX + 85, startPosY + 59, 13, 13); - g.drawOval(startPosX + 100, startPosY + 59, 13, 13); - g.drawOval(startPosX + 115, startPosY + 59, 13, 13); - - - /* два крайних на гусенице*/ - g.fillOval(startPosX + 10, startPosY + 50, 25, 25); - g.fillOval(startPosX + 135, startPosY + 50, 25, 25); - } + public void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) { + g2d.setColor(Color.BLACK); + g2d.fillOval(x, y, w, h); } } diff --git a/src/DrawingWheelsBlueCrom.java b/src/DrawingWheelsBlueCrom.java new file mode 100644 index 0000000..02e96ed --- /dev/null +++ b/src/DrawingWheelsBlueCrom.java @@ -0,0 +1,33 @@ +import java.awt.*; + +public class DrawingWheelsBlueCrom implements IDrawingWheels{ + private WheelsCount _wheelsCount; + @Override + public void SetWheelsCount(int wheelsCount) { + for (WheelsCount val : WheelsCount.values()) { + if (val.count == wheelsCount) { + _wheelsCount = val; + return; + } + } + this._wheelsCount = WheelsCount.Five; + } + + @Override + public WheelsCount GetWheelsCount() { + return _wheelsCount; + } + + @Override + public void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) { + g2d.setColor(Color.GRAY); + g2d.drawOval(x, y + 3, w-5, h-5); + g2d.setColor(Color.GREEN); + g2d.drawOval(x - 2, y - 2, w, h); + g2d.setColor(Color.WHITE); + g2d.drawOval(x + 3, y, w - 10, h - 10); + + g2d.setColor(Color.BLACK); + g2d.drawOval(x, y, w, h); + } +} diff --git a/src/EntityUsta.java b/src/EntityUsta.java index 72ce791..556a80a 100644 --- a/src/EntityUsta.java +++ b/src/EntityUsta.java @@ -4,21 +4,18 @@ public class EntityUsta { public int Speed; public double Weight; public Color BodyColor; - public Color AdditionalColor; - public boolean BodyKit; - public boolean Pushka; + public EntityUsta(int speed, double weight, Color bodyColor) { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } public double Step() { return (double) Speed * 100 / Weight; } - public void Init(int speed, double weight, Color bodyColor, Color additionalColor, - boolean bodyKit, boolean pushka) - { + public void Init(int speed, double weight, Color bodyColor, Color additionalColor, boolean horns, boolean seifbatteries) { Speed = speed; Weight = weight; BodyColor = bodyColor; - AdditionalColor = additionalColor; - BodyKit = bodyKit; - Pushka = pushka; } } diff --git a/src/EntityUstaBat.java b/src/EntityUstaBat.java new file mode 100644 index 0000000..e5ff52c --- /dev/null +++ b/src/EntityUstaBat.java @@ -0,0 +1,15 @@ +import java.awt.*; + +public class EntityUstaBat extends EntityUsta { + public Color AdditionalColor; + public boolean Pushka; + public boolean BodyKit; + public EntityUstaBat(int speed, double weight, Color bodyColor, Color additionalColor, boolean pushka, boolean bodyKit) + { + super(speed, weight, bodyColor); + AdditionalColor = additionalColor; + Pushka = pushka; + BodyKit = bodyKit; + } + +} diff --git a/src/SelfPropelledArtilleryUnit.form b/src/FormUstaBat.form similarity index 52% rename from src/SelfPropelledArtilleryUnit.form rename to src/FormUstaBat.form index 16c6120..327f8a8 100644 --- a/src/SelfPropelledArtilleryUnit.form +++ b/src/FormUstaBat.form @@ -1,39 +1,93 @@ -