diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 47b656f..da7d021 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -4,7 +4,10 @@
-
+
+
+
+
@@ -29,7 +32,8 @@
diff --git a/Hydroplane/.idea/.gitignore b/Hydroplane/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/Hydroplane/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/Hydroplane/.idea/compiler.xml b/Hydroplane/.idea/compiler.xml
new file mode 100644
index 0000000..e1988ff
--- /dev/null
+++ b/Hydroplane/.idea/compiler.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/.idea/encodings.xml b/Hydroplane/.idea/encodings.xml
new file mode 100644
index 0000000..aa00ffa
--- /dev/null
+++ b/Hydroplane/.idea/encodings.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/.idea/jarRepositories.xml b/Hydroplane/.idea/jarRepositories.xml
new file mode 100644
index 0000000..712ab9d
--- /dev/null
+++ b/Hydroplane/.idea/jarRepositories.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/.idea/misc.xml b/Hydroplane/.idea/misc.xml
new file mode 100644
index 0000000..e5d6295
--- /dev/null
+++ b/Hydroplane/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/.idea/uiDesigner.xml b/Hydroplane/.idea/uiDesigner.xml
new file mode 100644
index 0000000..2b63946
--- /dev/null
+++ b/Hydroplane/.idea/uiDesigner.xml
@@ -0,0 +1,124 @@
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+ -
+
+
+
+
+ -
+
+
+ -
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/.idea/vcs.xml b/Hydroplane/.idea/vcs.xml
new file mode 100644
index 0000000..6c0b863
--- /dev/null
+++ b/Hydroplane/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Hydroplane/src/main/java/org/example/Direction.java b/Hydroplane/src/main/java/org/example/Direction.java
new file mode 100644
index 0000000..4160509
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/Direction.java
@@ -0,0 +1,9 @@
+package org.example;
+
+public enum Direction {
+ Up,
+ Down,
+ Left,
+ Right;
+}
+
diff --git a/Hydroplane/src/main/java/org/example/DrawingHydroplane.java b/Hydroplane/src/main/java/org/example/DrawingHydroplane.java
new file mode 100644
index 0000000..8859634
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/DrawingHydroplane.java
@@ -0,0 +1,147 @@
+package org.example;
+
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.Timer;
+import java.awt.event.*;
+
+public class DrawingHydroplane{
+
+ private WindowDrawing windowDrawing;
+
+ public EntityHydroplane _EntityHydroplane;
+
+ private int _pictureWidth;
+
+ private int _pictureHeight;
+
+ private int _startPosX;
+
+ private int _startPosY;
+
+ private int _planeWidth = 190;
+
+ private int _planeHeight = 80;
+
+ public boolean Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, boolean boat, boolean bobber, int numWindow, int width, int height)
+ {
+ _pictureWidth = width;
+ _pictureHeight = height;
+ if (_pictureHeight < _planeHeight || _pictureWidth < _planeWidth)
+ return false;
+ _EntityHydroplane = new EntityHydroplane();
+ _EntityHydroplane.Init(speed, weight, bodyColor, additionalColor,boat, bobber, numWindow);
+
+ windowDrawing = new WindowDrawing();
+ windowDrawing.setNumWindow(numWindow);
+ return true;
+ }
+
+ public void SetPosition(int x, int y)
+ {
+ _startPosX = Math.min(x, _pictureWidth-_planeWidth);
+ _startPosY = Math.min(y, _pictureHeight-_planeHeight);
+ }
+
+ public void MoveTransport(Direction direction)
+ {
+ if (_EntityHydroplane == null){
+ return;
+ }
+ switch (direction)
+ {
+ case Left:
+ if (_startPosX - _EntityHydroplane.Step > 0)
+ {
+ _startPosX -= (int)_EntityHydroplane.Step;
+ }
+ break;
+ case Up:
+ if (_startPosY - _EntityHydroplane.Step > 0)
+ {
+ _startPosY -= (int)_EntityHydroplane.Step;
+ }
+ break;
+ case Right:
+ if (_startPosX + _planeWidth + _EntityHydroplane.Step < _pictureWidth)
+ {
+ _startPosX += (int)_EntityHydroplane.Step;
+ }
+ break;
+ case Down:
+ if (_startPosY + _planeHeight + _EntityHydroplane.Step < _pictureHeight)
+ {
+ _startPosY += (int)_EntityHydroplane.Step;
+ }
+ break;
+ }
+ }
+
+ public void DrawTransport(Graphics2D g)
+ {
+
+ if (_EntityHydroplane == null)
+ {
+ return;
+ }
+
+ g.setColor(_EntityHydroplane.BodyColor);
+ g.fillPolygon(
+ new int[]{ _startPosX + 5, _startPosX + 5, _startPosX + 130, _startPosX + 160, _startPosX + 130, _startPosX + 130, _startPosX + 55 },
+ new int[]{ _startPosY, _startPosY + 55, _startPosY + 55, _startPosY + 40, _startPosY + 40, _startPosY + 25, _startPosY + 25 },
+ 7);
+
+ g.fillRect(_startPosX + 65, _startPosY + 55, 5, 15);
+ g.fillRect(_startPosX + 125, _startPosY + 55, 5, 15);
+
+ g.setColor(_EntityHydroplane.AdditionalColor);
+
+ g.fillPolygon(
+ new int[]{ _startPosX + 160, _startPosX + 130, _startPosX + 130 },
+ new int[]{ _startPosY + 40, _startPosY + 40, _startPosY + 25 },
+ 3
+ );
+
+ g.drawRect(_startPosX + 5, _startPosY + 25, 125, 30);
+
+ g.drawLine(_startPosX + 130, _startPosY + 25, _startPosX + 160, _startPosY + 40);
+ g.drawLine(_startPosX + 130, _startPosY + 55, _startPosX + 160, _startPosY + 40);
+ g.drawLine(_startPosX + 130, _startPosY + 40, _startPosX + 160, _startPosY + 40);
+
+ g.drawOval(_startPosX + 35, _startPosY + 43, 80, 7);
+
+ g.drawLine(_startPosX + 65, _startPosY + 55, _startPosX + 65, _startPosY + 70);
+ g.drawLine(_startPosX + 70, _startPosY + 55, _startPosX + 70, _startPosY + 70);
+ g.drawLine(_startPosX + 125, _startPosY + 55, _startPosX + 125, _startPosY + 70);
+ g.drawLine(_startPosX + 130, _startPosY + 55, _startPosX + 130, _startPosY + 70);
+
+ windowDrawing.Draw(_startPosX, _startPosY, _EntityHydroplane.AdditionalColor, g);
+
+ if (_EntityHydroplane.Bobber) {
+ g.fillPolygon(
+ new int[]{ _startPosX + 55, _startPosX + 55, _startPosX + 155, _startPosX + 175 },
+ new int[]{ _startPosY + 70, _startPosY + 80, _startPosY + 80, _startPosY + 70 },
+ 4
+ );
+ g.drawPolygon(
+ new int[]{ _startPosX + 55, _startPosX + 55, _startPosX + 155, _startPosX + 175 },
+ new int[]{ _startPosY + 70, _startPosY + 80, _startPosY + 80, _startPosY + 70 },
+ 4
+ );
+ }
+ else {
+ g.fillOval(_startPosX + 60, _startPosY + 70, 15, 15);
+ g.fillOval(_startPosX + 120, _startPosY + 70, 15, 15);
+
+ g.drawOval(_startPosX + 60, _startPosY + 70, 15, 15);
+ g.drawOval(_startPosX + 120, _startPosY + 70, 15, 15);
+ }
+
+ if (_EntityHydroplane.Boat){
+ g.fillOval(_startPosX, _startPosY + 21, 32, 8);
+ g.drawOval(_startPosX, _startPosY + 21, 32, 8);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Hydroplane/src/main/java/org/example/EntityHydroplane.java b/Hydroplane/src/main/java/org/example/EntityHydroplane.java
new file mode 100644
index 0000000..91c908d
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/EntityHydroplane.java
@@ -0,0 +1,39 @@
+package org.example;
+
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.Timer;
+import java.awt.event.*;
+
+public class EntityHydroplane{
+
+ public int Speed;
+
+ public double Weight;
+
+ public Color BodyColor;
+
+ public Color AdditionalColor;
+
+ public boolean Boat;
+
+ public boolean Bobber;
+
+ public double Step;
+
+ public int numWindow;
+
+ public void Init(int speed, double weight, Color bodyColor, Color
+ additionalColor, boolean boat, boolean bobber, int _numWindow)
+ {
+ numWindow = _numWindow;
+ Speed = speed;
+ Weight = weight;
+ BodyColor = bodyColor;
+ AdditionalColor = additionalColor;
+ Boat = boat;
+ Bobber = bobber;
+ Step = (double)Speed * 100 / Weight;
+ }
+}
diff --git a/Hydroplane/src/main/java/org/example/FormHydroplane.java b/Hydroplane/src/main/java/org/example/FormHydroplane.java
new file mode 100644
index 0000000..04fe262
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/FormHydroplane.java
@@ -0,0 +1,124 @@
+package org.example;
+
+import java.awt.*;
+import java.util.*;
+import javax.swing.*;
+import javax.swing.Timer;
+import java.awt.event.*;
+
+public class FormHydroplane{
+ private DrawingHydroplane _drawingHydroplane;
+ Canvas canv;
+
+ public void Draw(){
+ canv.repaint();
+ }
+
+ public FormHydroplane(){
+ JFrame w=new JFrame ("Hydroplane");
+ JButton buttonCreate = new JButton("create");
+ JButton up = new JButton();
+ up.setBorderPainted(false);
+ up.setFocusPainted(false);
+ up.setContentAreaFilled(false);
+ up.setName("up");
+ up.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\up.png"));
+ JButton down = new JButton();
+ down.setBorderPainted(false);
+ down.setFocusPainted(false);
+ down.setContentAreaFilled(false);
+ down.setName("down");
+ down.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\down.png"));
+ JButton left = new JButton();
+ left.setBorderPainted(false);
+ left.setFocusPainted(false);
+ left.setContentAreaFilled(false);
+ left.setName("left");
+ left.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\left.png"));
+ JButton right = new JButton();
+ right.setBorderPainted(false);
+ right.setFocusPainted(false);
+ right.setContentAreaFilled(false);
+ right.setName("right");
+ right.setIcon(new ImageIcon("C:\\RPP HARD\\PIbd-22_Fedorenko_G.Y._Hydroplane_HARD\\Hydroplane\\src\\main\\java\\org\\example\\images\\right.png"));
+
+ buttonCreate.addActionListener(
+ new ActionListener() {
+ public void actionPerformed(ActionEvent e){
+ //System.out.println(e.getActionCommand());
+ Random random = new Random();
+ _drawingHydroplane = new DrawingHydroplane();
+ _drawingHydroplane.Init(random.nextInt(100, 300), random.nextInt(1000, 3000),
+ new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
+ new Color(random.nextInt(0, 256), random.nextInt(0, 256), random.nextInt(0, 256)),
+ random.nextInt(0, 2) == 1, random.nextInt(0, 2) == 1,
+ random.nextInt(1, 4)*10, 1000, 560);
+ _drawingHydroplane.SetPosition(random.nextInt(10, 100), random.nextInt(10, 100));
+ canv._drawingHydroplane = _drawingHydroplane;
+ Draw();
+ }
+ }
+ );
+ ActionListener actioListener = new ActionListener() {
+ public void actionPerformed(ActionEvent e){
+ //System.out.println(((JButton)(e.getSource())).getName());
+ if (_drawingHydroplane == null)
+ {
+ return;
+ }
+ switch(((JButton)(e.getSource())).getName()){
+ case "up":
+ _drawingHydroplane.MoveTransport(Direction.Up);
+ break;
+ case "down":
+ _drawingHydroplane.MoveTransport(Direction.Down);
+ break;
+ case "left":
+ _drawingHydroplane.MoveTransport(Direction.Left);
+ break;
+ case "right":
+ _drawingHydroplane.MoveTransport(Direction.Right);
+ break;
+ }
+ Draw();
+ }
+ };
+ up.addActionListener(actioListener);
+ down.addActionListener(actioListener);
+ left.addActionListener(actioListener);
+ right.addActionListener(actioListener);
+
+ w.setSize (1000, 600);
+ w.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
+ w.setLayout(null);
+ canv = new Canvas();
+ canv.setBounds(0, 0, 1000, 600);
+ buttonCreate.setBounds(2, 540, 100, 20);
+ up.setBounds(900, 480, 40, 40);
+ down.setBounds(900, 520, 40, 40);
+ left.setBounds(860, 520, 40, 40);
+ right.setBounds(940, 520, 40, 40);
+ w.add(canv);
+ w.add(buttonCreate);
+ w.add(up);
+ w.add(down);
+ w.add(left);
+ w.add(right);
+ w.setVisible (true);
+ }
+}
+
+class Canvas extends JComponent{
+ public DrawingHydroplane _drawingHydroplane;
+ public Canvas(){
+ }
+ public void paintComponent (Graphics g){
+ if (_drawingHydroplane == null){
+ return;
+ }
+ super.paintComponents (g) ;
+ Graphics2D g2d = (Graphics2D)g;
+ _drawingHydroplane.DrawTransport(g2d);
+ super.repaint();
+ }
+}
\ No newline at end of file
diff --git a/Hydroplane/src/main/java/org/example/Main.java b/Hydroplane/src/main/java/org/example/Main.java
index 407f157..aa24a92 100644
--- a/Hydroplane/src/main/java/org/example/Main.java
+++ b/Hydroplane/src/main/java/org/example/Main.java
@@ -2,6 +2,6 @@ package org.example;
public class Main {
public static void main(String[] args) {
- System.out.println("Hello world!");
+ new FormHydroplane();
}
}
\ No newline at end of file
diff --git a/Hydroplane/src/main/java/org/example/NumWindow.java b/Hydroplane/src/main/java/org/example/NumWindow.java
new file mode 100644
index 0000000..10c51dd
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/NumWindow.java
@@ -0,0 +1,8 @@
+package org.example;
+
+public enum NumWindow
+{
+ tenWindows,
+ twentyWindows,
+ thirtyWindows
+}
\ No newline at end of file
diff --git a/Hydroplane/src/main/java/org/example/WindowDrawing.java b/Hydroplane/src/main/java/org/example/WindowDrawing.java
new file mode 100644
index 0000000..c9a722a
--- /dev/null
+++ b/Hydroplane/src/main/java/org/example/WindowDrawing.java
@@ -0,0 +1,60 @@
+package org.example;
+
+import java.awt.*;
+
+public class WindowDrawing{
+ private NumWindow numWindow;
+
+ public NumWindow getSomeProperty() {
+ return numWindow;
+ }
+
+ public void setNumWindow(int kWindow){
+ switch(kWindow){
+ case 10:
+ numWindow = NumWindow.tenWindows;
+ break;
+ case 20:
+ numWindow = NumWindow.twentyWindows;
+ break;
+ case 30:
+ numWindow = NumWindow.thirtyWindows;
+ break;
+ default:
+ numWindow = NumWindow.tenWindows;
+ System.out.println("Произошел косяк с количеством, но давайте их будет 10, вообще было " + kWindow);
+ break;
+ }
+ }
+
+ void Draw(int _startPosX, int _startPosY, Color color, Graphics2D g){
+ g.setColor(color);
+ switch (numWindow) {
+ case tenWindows -> {
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
+ }
+ }
+ case twentyWindows -> {
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
+ }
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 4, 4, 4);
+ }
+ }
+ case thirtyWindows -> {
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30, 4, 4);
+ }
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 4, 4, 4);
+ }
+ for (int i = 0; i < 10; i++) {
+ g.fillOval(_startPosX + 35 + i * 8, _startPosY + 30 + 8, 4, 4);
+ }
+ }
+ }
+ }
+}
+
diff --git a/Hydroplane/src/main/java/org/example/images/down.png b/Hydroplane/src/main/java/org/example/images/down.png
new file mode 100644
index 0000000..30e8561
Binary files /dev/null and b/Hydroplane/src/main/java/org/example/images/down.png differ
diff --git a/Hydroplane/src/main/java/org/example/images/left.png b/Hydroplane/src/main/java/org/example/images/left.png
new file mode 100644
index 0000000..d7cd963
Binary files /dev/null and b/Hydroplane/src/main/java/org/example/images/left.png differ
diff --git a/Hydroplane/src/main/java/org/example/images/right.png b/Hydroplane/src/main/java/org/example/images/right.png
new file mode 100644
index 0000000..3387a09
Binary files /dev/null and b/Hydroplane/src/main/java/org/example/images/right.png differ
diff --git a/Hydroplane/src/main/java/org/example/images/up.png b/Hydroplane/src/main/java/org/example/images/up.png
new file mode 100644
index 0000000..fb7362b
Binary files /dev/null and b/Hydroplane/src/main/java/org/example/images/up.png differ