Compare commits

...

8 Commits

27 changed files with 805 additions and 0 deletions

3
.idea/.gitignore generated vendored Normal file
View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

6
.idea/misc.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="openjdk-20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

8
.idea/modules.xml generated Normal file
View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/PIbd-21_Bakalskaya_E.D._ElectricLocomotive._HARD.iml" filepath="$PROJECT_DIR$/.idea/PIbd-21_Bakalskaya_E.D._ElectricLocomotive._HARD.iml" />
</modules>
</component>
</project>

124
.idea/uiDesigner.xml generated Normal file
View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

6
.idea/vcs.xml generated Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,173 @@
package ProjectElectricLocomotive;
import java.awt.*;
public class DrawingElectricLocomotive {
public EntityElectricLocomotive EntityElectricLocomotive;
private DrawingWheel _drawingWheel;
private int _pictureWidth;
private int _pictureHeight;
private int _startPosX;
private int _startPosY;
private final int _locoWidth = 150;
private final int _locoHeight = 50;
public boolean Init(int speed, double weight, Color bodyColor, Color additionalColor,
boolean horns, boolean seifbatteries, int width, int height)
{
if (width < _locoWidth || height < _locoHeight)
{
return false;
}
_pictureWidth = width;
_pictureHeight = height;
EntityElectricLocomotive = new EntityElectricLocomotive();
_drawingWheel = new DrawingWheel();
EntityElectricLocomotive.Init(speed, weight, bodyColor, additionalColor, horns, seifbatteries);
return true;
}
public void SetWheelsCount(int weelsCount) {
_drawingWheel.SetWheelsCount(weelsCount);
}
public void SetPosition(int x, int y)
{
if (x < 0 || x + _locoWidth > _pictureWidth)
{
x = 20;
}
if (y < 0 || y + _locoHeight > _pictureHeight)
{
y = 20;
}
_startPosX = x;
_startPosY = y;
}
public void MoveTransport(DyrectionType direction){
if(EntityElectricLocomotive == null) return;
switch(direction)
{
case Up -> {
if(_startPosY - EntityElectricLocomotive.Step() >= 0)
_startPosY -= (int) EntityElectricLocomotive.Step();
}
case Down -> {
if(_startPosY + EntityElectricLocomotive.Step() + _locoHeight <= _pictureHeight)
_startPosY += (int) EntityElectricLocomotive.Step();
}
case Left -> {
if(_startPosX - EntityElectricLocomotive.Step() >= 0)
_startPosX -= (int) EntityElectricLocomotive.Step();
}
case Right -> {
if(_startPosX + EntityElectricLocomotive.Step() + _locoWidth <= _pictureWidth)
_startPosX += (int) EntityElectricLocomotive.Step();
}
}
}
public void DrawTransport(Graphics g) {
if (EntityElectricLocomotive == null) {
return;
}
Graphics2D g2d = (Graphics2D) g;
Color bodyColor = EntityElectricLocomotive.BodyColor;
Color additionalColor = EntityElectricLocomotive.AdditionalColor;
Color blackBrush = Color.BLACK;
Color windowsColor = Color.BLUE;
_drawingWheel.DrawWheels(g, additionalColor, _startPosX, _startPosY, 5, 5);
if(EntityElectricLocomotive.Horns)
{
g2d.fillRect(_startPosX + 30, _startPosY + 15, 20, 5);
g2d.drawLine(_startPosX + 40, _startPosY + 15, _startPosX + 50, _startPosY + 10);
g2d.drawLine(_startPosX + 50, _startPosY + 10, _startPosX + 45, _startPosY);
g2d.drawLine(_startPosX + 45, _startPosY + 15, _startPosX + 50, _startPosY + 10);
g2d.drawLine(_startPosX + 50, _startPosY + 10, _startPosX + 40, _startPosY);
g2d.setColor(blackBrush);
}
//locomotive
Polygon loco = new Polygon();
loco.addPoint(_startPosX, _startPosY + 40);
loco.addPoint(_startPosX, _startPosY + 30);
loco.addPoint(_startPosX + 20, _startPosY + 20);
loco.addPoint(_startPosX + 70, _startPosY + 20);
loco.addPoint(_startPosX +80, _startPosY + 30);
loco.addPoint(_startPosX +80, _startPosY + 40);
loco.addPoint(_startPosX +75, _startPosY + 45);
loco.addPoint(_startPosX +5, _startPosY + 45);
loco.addPoint(_startPosX, _startPosY + 40);
g2d.setColor(blackBrush);
g2d.drawPolygon(loco);
g2d.setColor(bodyColor);
g2d.fillPolygon(loco);
// windows
Polygon window = new Polygon();
window.addPoint(_startPosX + 10, _startPosY + 30);
window.addPoint(_startPosX +15, _startPosY + 25);
window.addPoint(_startPosX + 20, _startPosY + 25);
window.addPoint(_startPosX + 20, _startPosY + 30);
window.addPoint(_startPosX +10, _startPosY + 30);
g2d.setColor(blackBrush);
g2d.drawPolygon(window);
g2d.setColor(windowsColor);
g2d.fillPolygon(window);
g2d.fillRect(_startPosX + 25, _startPosY + 25, 10, 5);
g2d.setColor(windowsColor);
g2d.drawRect(_startPosX + 25, _startPosY + 25, 10, 5);
g2d.setColor(blackBrush);
//locomotive
if(EntityElectricLocomotive.SeifBatteries)
{
g2d.drawRect(_startPosX + 50, _startPosY + 25, 20, 10);
g2d.setColor(blackBrush);
}
//обязательные колеса
//loco
g2d.fillOval(_startPosX + 10, _startPosY + 45, 5, 5);
g2d.fillOval(_startPosX + 25, _startPosY + 45, 5, 5);
g2d.fillOval(_startPosX + 50, _startPosY + 45, 5, 5);
g2d.fillOval(_startPosX + 65, _startPosY + 45, 5, 5);
//telega
g2d.setColor(blackBrush);
g2d.fillOval(_startPosX + 95, _startPosY + 45, 5, 5);
g2d.fillOval(_startPosX + 140, _startPosY + 45, 5, 5);
//telejka
Polygon telega = new Polygon();
telega.addPoint(_startPosX + 90, _startPosY + 25);
telega.addPoint(_startPosX + 95, _startPosY + 20);
telega.addPoint(_startPosX + 145, _startPosY + 20);
telega.addPoint(_startPosX + 150, _startPosY + 25);
telega.addPoint(_startPosX + 150, _startPosY + 45);
telega.addPoint(_startPosX + 90, _startPosY + 45);
telega.addPoint(_startPosX + 90, _startPosY + 25);
g2d.setColor(additionalColor);
g2d.fillPolygon(telega);
g2d.setColor(blackBrush);
g2d.drawPolygon(telega);
//telejka
//телега окна
g2d.setColor(blackBrush);
g.drawLine(_startPosX + 80, _startPosY + 40, _startPosX + 90, _startPosY + 40);
g2d.setColor(windowsColor); g.fillRect(_startPosX + 95, _startPosY + 30, 10, 5);
g.fillRect(_startPosX + 115, _startPosY + 30, 10, 5);
g.fillRect(_startPosX + 135, _startPosY + 30, 10, 5);
}
}

View File

@ -0,0 +1,42 @@
package ProjectElectricLocomotive;
import java.awt.*;
public class DrawingWheel {
private WheelsCount _wheelsCount;
public void SetWheelsCount(int enginesCount) {
for (WheelsCount val : WheelsCount.values()) {
if (val.count == enginesCount) {
this._wheelsCount = val;
return;
}
}
}
private void DrawWheel(Graphics2D g2d, Color color, int x, int y, int w, int h) {
g2d.setColor(Color.BLACK);
g2d.fillOval(x, y, w, h);
}
public void DrawWheels(Graphics g, Color color, int startPosX, int startPosY, int drawingWidth, int drawingHeight) {
if (_wheelsCount == null) {
return;
}
Graphics2D g2d = (Graphics2D) g;
int wheelWidth = 5;
int wheelHeight = 5;
if (_wheelsCount.count >= _wheelsCount.Three.count) {
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
);
}
if (_wheelsCount.count >= _wheelsCount.Four.count) {
DrawWheel(g2d, color, startPosX + 105, startPosY + 45, wheelWidth, wheelHeight
);
DrawWheel(g2d, color, startPosX + 130, startPosY + 45, wheelWidth, wheelHeight
);
}
}
}

View File

@ -0,0 +1,5 @@
package ProjectElectricLocomotive;
public enum DyrectionType {
Up, Down, Left, Right
}

View File

@ -0,0 +1,26 @@
package ProjectElectricLocomotive;
import java.awt.*;
public class EntityElectricLocomotive {
public int Speed;
public double Weight;
public Color BodyColor;
public Color AdditionalColor;
public boolean Horns;
public boolean SeifBatteries;
public double Step()
{
return (double) Speed * 100 / Weight;
}
public void Init(int speed, double weight, Color bodyColor, Color additionalColor,
boolean horns, boolean seifBatteries)
{
Speed = speed;
Weight = weight;
BodyColor = bodyColor;
AdditionalColor = additionalColor;
Horns = horns;
SeifBatteries = seifBatteries;
}
}

View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ProjectElectricLocomotive.FormElectricLocomotive">
<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"/>
</constraints>
<properties/>
<border type="none">
<font/>
</border>
<children>
<hspacer id="ce44b">
<constraints>
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="17764">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="2fa92" class="javax.swing.JButton" binding="buttonDown">
<constraints>
<grid row="2" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="30" height="30"/>
<preferred-size width="30" height="30"/>
<maximum-size width="30" height="30"/>
</grid>
</constraints>
<properties>
<hideActionText value="true"/>
<horizontalTextPosition value="0"/>
<icon value="ProjectElectricLocomotive/img/arrowDown.jpg"/>
<text value=""/>
</properties>
</component>
<component id="326c5" class="javax.swing.JButton" binding="buttonLeft">
<constraints>
<grid row="2" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="0" indent="0" use-parent-layout="false">
<minimum-size width="30" height="30"/>
<preferred-size width="30" height="30"/>
<maximum-size width="30" height="30"/>
</grid>
</constraints>
<properties>
<hideActionText value="false"/>
<horizontalTextPosition value="0"/>
<icon value="ProjectElectricLocomotive/img/arrowLeft.jpg"/>
<text value=""/>
</properties>
<clientProperties>
<hideActionText class="java.lang.Boolean" value="false"/>
</clientProperties>
</component>
<component id="cc460" class="javax.swing.JButton" binding="buttonRight">
<constraints>
<grid row="2" column="4" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="30" height="30"/>
<preferred-size width="30" height="30"/>
<maximum-size width="30" height="30"/>
</grid>
</constraints>
<properties>
<hideActionText value="true"/>
<horizontalTextPosition value="0"/>
<icon value="ProjectElectricLocomotive/img/arrowRight.jpg"/>
<text value=""/>
</properties>
</component>
<component id="bbbb" class="javax.swing.JButton" binding="buttonUp">
<constraints>
<grid row="1" column="3" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
<minimum-size width="30" height="30"/>
<preferred-size width="30" height="30"/>
<maximum-size width="30" height="30"/>
</grid>
</constraints>
<properties>
<enabled value="true"/>
<hideActionText value="false"/>
<horizontalTextPosition value="0"/>
<icon value="ProjectElectricLocomotive/img/arrowUp.jpg"/>
<text value=""/>
</properties>
<clientProperties>
<hideActionText class="java.lang.Boolean" value="false"/>
</clientProperties>
</component>
<component id="6cb47" class="javax.swing.JButton" binding="buttonCreate">
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<text value="Создать"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -0,0 +1,79 @@
package ProjectElectricLocomotive;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.util.Random;
public class FormElectricLocomotive {
DrawingElectricLocomotive _drawingElectricLocomotive = new DrawingElectricLocomotive();
private JButton buttonCreate;
private JPanel pictureBox;
private JButton buttonUp;
private JButton buttonDown;
private JButton buttonLeft;
private JButton buttonRight;
public JPanel getPictureBox() {
return pictureBox;
}
public FormElectricLocomotive()
{
buttonUp.setName("buttonUp");
buttonDown.setName("buttonDown");
buttonLeft.setName("buttonLeft");
buttonRight.setName("buttonRight");
buttonCreate.addActionListener(e -> {
_drawingElectricLocomotive = new DrawingElectricLocomotive();
Random random = new Random();
_drawingElectricLocomotive.Init(
random.nextInt(100, 300),
random.nextInt(1000, 3000),
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
new Color(random.nextInt(256), random.nextInt(256), random.nextInt(256)),
random.nextBoolean(),
random.nextBoolean(),
pictureBox.getWidth(),
pictureBox.getHeight()
);
_drawingElectricLocomotive.SetWheelsCount(random.nextInt(2, 5));
_drawingElectricLocomotive.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
Draw();
});
ActionListener buttonMoveClickedListener = e -> {
String buttonName = ((JButton) e.getSource()).getName();
switch (buttonName) {
case ("buttonUp") -> {
_drawingElectricLocomotive.MoveTransport(DyrectionType.Up);
}
case ("buttonDown") -> {
_drawingElectricLocomotive.MoveTransport(DyrectionType.Down);
}
case ("buttonLeft") -> {
_drawingElectricLocomotive.MoveTransport(DyrectionType.Left);
}
case ("buttonRight") -> {
_drawingElectricLocomotive.MoveTransport(DyrectionType.Right);
}
}
Draw();
};
buttonUp.addActionListener(buttonMoveClickedListener);
buttonDown.addActionListener(buttonMoveClickedListener);
buttonLeft.addActionListener(buttonMoveClickedListener);
buttonRight.addActionListener(buttonMoveClickedListener);
}
public void Draw() {
if (_drawingElectricLocomotive.EntityElectricLocomotive == null) {
return;
}
Graphics g = pictureBox.getGraphics();
pictureBox.paint(g);
_drawingElectricLocomotive.DrawTransport(g);
}
}

View File

@ -0,0 +1,8 @@
package ProjectElectricLocomotive;
public class Main {
public static void main(String[] args)
{
MainFrameElectricLocomotive mainFrameElectricLocomotive = new MainFrameElectricLocomotive();
}
}

View File

@ -0,0 +1,19 @@
package ProjectElectricLocomotive;
import javax.swing.*;
public class MainFrameElectricLocomotive extends JFrame {
private FormElectricLocomotive _formElectricLocomotive;
public MainFrameElectricLocomotive() {
super();
setTitle("ElectroLoco");
setDefaultCloseOperation(EXIT_ON_CLOSE);
_formElectricLocomotive = new FormElectricLocomotive();
setContentPane(_formElectricLocomotive.getPictureBox());
setDefaultLookAndFeelDecorated(false);
setLocation(500, 50);
pack();
setVisible(true);
}
}

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

View File

@ -0,0 +1,26 @@
# ---> Java
# Compiled class file
*.class
# Log file
*.log
# BlueJ files
*.ctxt
# Mobile Tools for Java (J2ME)
.mtj.tmp/
# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

View File

@ -0,0 +1,3 @@
# Default ignored files
/shelf/
/workspace.xml

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_19" project-jdk-name="openjdk-20" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/PIbd-21_Bakalskaya_E.D._ElectricLocomotive._HARD.iml" filepath="$PROJECT_DIR$/.idea/PIbd-21_Bakalskaya_E.D._ElectricLocomotive._HARD.iml" />
</modules>
</component>
</project>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Palette2">
<group name="Swing">
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
</item>
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
</item>
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
</item>
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
<initial-values>
<property name="text" value="Button" />
</initial-values>
</item>
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="RadioButton" />
</initial-values>
</item>
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
<initial-values>
<property name="text" value="CheckBox" />
</initial-values>
</item>
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
<initial-values>
<property name="text" value="Label" />
</initial-values>
</item>
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
<preferred-size width="150" height="-1" />
</default-constraints>
</item>
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
</item>
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
<preferred-size width="150" height="50" />
</default-constraints>
</item>
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
<preferred-size width="200" height="200" />
</default-constraints>
</item>
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
</item>
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
</item>
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
</item>
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
<preferred-size width="-1" height="20" />
</default-constraints>
</item>
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
</item>
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
</item>
</group>
</component>
</project>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>

View File

@ -0,0 +1,2 @@
# PIbd-21_Bakalskaya_E.D._ElectricLocomotive._HARD