Готовая лаба

This commit is contained in:
ekallin 2023-10-08 20:20:04 +04:00
parent ba8bcf5f78
commit e89ef66010
5 changed files with 14 additions and 11 deletions

View File

@ -26,19 +26,19 @@ public class DrawingElectricLocomotive {
return true;
}
public void SetWheelsCount(int weelsCount) {
_drawingWheel.SetWheelsCount(weelsCount);
public void SetWheelsCount(int wheelsCount) {
_drawingWheel.SetWheelsCount(wheelsCount);
}
public void SetPosition(int x, int y)
{
if (x < 0 || x + _locoWidth > _pictureWidth)
{
x = 20;
x = _pictureWidth - _locoWidth;
}
if (y < 0 || y + _locoHeight > _pictureHeight)
{
y = 20;
y = _pictureHeight - _locoHeight;
}
_startPosX = x;
_startPosY = y;

View File

@ -4,10 +4,10 @@ import java.awt.*;
public class DrawingWheel {
private WheelsCount _wheelsCount;
public void SetWheelsCount(int enginesCount) {
public void SetWheelsCount(int wheelsCount) {
for (WheelsCount val : WheelsCount.values()) {
if (val.count == enginesCount) {
this._wheelsCount = val;
if (val.count == wheelsCount) {
_wheelsCount = val;
return;
}
}

View File

@ -3,9 +3,12 @@
<grid id="27dc6" binding="pictureBox" layout-manager="GridLayoutManager" row-count="3" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="24" y="37" width="635" height="383"/>
<xy x="24" y="37" width="635" height="500"/>
</constraints>
<properties/>
<properties>
<minimumSize width="500" height="300"/>
<preferredSize width="500" height="300"/>
</properties>
<border type="none">
<font/>
</border>

View File

@ -12,7 +12,7 @@ public class MainFrameElectricLocomotive extends JFrame {
_formElectricLocomotive = new FormElectricLocomotive();
setContentPane(_formElectricLocomotive.getPictureBox());
setDefaultLookAndFeelDecorated(false);
setLocation(500, 50);
setLocation(500, 200);
pack();
setVisible(true);
}

View File

@ -1,7 +1,7 @@
package ProjectElectricLocomotive;
public enum WheelsCount {
Two(2), Three(3), Four(4);
/* Two(2),*/ Three(3), Four(4);
public final int count;
WheelsCount(int count) {
this.count = count;