From 11be96c351086354cc07656241da991ed4e6a5b1 Mon Sep 17 00:00:00 2001
From: abazov73 <92822431+abazov73@users.noreply.github.com>
Date: Tue, 13 Dec 2022 13:21:24 +0400
Subject: [PATCH] =?UTF-8?q?=D0=A8=D0=B5=D1=81=D1=82=D0=B0=D1=8F=20=D0=BB?=
=?UTF-8?q?=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=B0?=
=?UTF-8?q?=D1=8F=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../DrawingObjectAirBomber.java | 10 ++
.../AirBomberPackage/ExtentionAirBomber.java | 77 +++++++++
.../src/AirBomberPackage/IDrawingObject.java | 2 +
.../JFrameMapWithSetAirBombers.form | 50 +++++-
.../JFrameMapWithSetAirBombers.java | 102 ++++++++++-
.../MapWithSetAirBombersGeneric.java | 26 +++
.../src/AirBomberPackage/MapsCollection.java | 162 +++++++++++++++++-
.../SetAirBombersGeneric.java | 17 ++
8 files changed, 435 insertions(+), 11 deletions(-)
create mode 100644 AirBomber/src/AirBomberPackage/ExtentionAirBomber.java
diff --git a/AirBomber/src/AirBomberPackage/DrawingObjectAirBomber.java b/AirBomber/src/AirBomberPackage/DrawingObjectAirBomber.java
index 66ee1b7..b2c78c8 100644
--- a/AirBomber/src/AirBomberPackage/DrawingObjectAirBomber.java
+++ b/AirBomber/src/AirBomberPackage/DrawingObjectAirBomber.java
@@ -57,4 +57,14 @@ public class DrawingObjectAirBomber implements IDrawingObject {
_airBomber.DrawTransport(g);
}
}
+
+ @Override
+ public String GetInfo() {
+ if (_airBomber != null) return ExtentionAirBomber.ExtentionedAirBomber.GetDataForSave(_airBomber);
+ else return "";
+ }
+
+ public static IDrawingObject Create(String data){
+ return new DrawingObjectAirBomber(ExtentionAirBomber.ExtentionedAirBomber.CreateDrawningAirBomber(data));
+ }
}
diff --git a/AirBomber/src/AirBomberPackage/ExtentionAirBomber.java b/AirBomber/src/AirBomberPackage/ExtentionAirBomber.java
new file mode 100644
index 0000000..5145857
--- /dev/null
+++ b/AirBomber/src/AirBomberPackage/ExtentionAirBomber.java
@@ -0,0 +1,77 @@
+/*
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
+ * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
+ */
+package AirBomberPackage;
+
+import java.awt.Color;
+
+/**
+ *
+ * @author Андрей
+ */
+public class ExtentionAirBomber{
+ public static class ExtentionedAirBomber {
+ ///
+ /// Разделитель для записи информации по объекту в файл
+ ///
+ private static String _separatorForObject = ":";
+ ///
+ /// Создание объекта из строки
+ ///
+ ///
+ ///
+ public static DrawingAirBomber CreateDrawningAirBomber(String info)
+ {
+ String[] strs = info.split(_separatorForObject);
+ if (strs.length == 7) //заменить на передачу RGB
+ {
+ EnginesType enginesType = null;
+ switch (strs[6]) {
+ case "DrawingEngines":
+ enginesType = EnginesType.RECTANGLE;
+ break;
+ case "DrawingEnginesTriangle":
+ enginesType = EnginesType.TRIANGLE;
+ break;
+ case "DrawingEnginesOval":
+ enginesType = EnginesType.OVAL;
+ break;
+ }
+ return new DrawingAirBomber(Integer.parseInt(strs[0]),
+ Integer.parseInt(strs[1]), new Color(Integer.parseInt(strs[2]), Integer.parseInt(strs[3]), Integer.parseInt(strs[4])), Integer.parseInt(strs[5]), enginesType);
+ }
+ if (strs.length == 13)
+ {
+ EnginesType enginesType = null;
+ switch (strs[6]) {
+ case "DrawingEngines":
+ enginesType = EnginesType.RECTANGLE;
+ break;
+ case "DrawingEnginesTriangle":
+ enginesType = EnginesType.TRIANGLE;
+ break;
+ case "DrawingEnginesOval":
+ enginesType = EnginesType.OVAL;
+ break;
+ }
+ return new DrawingHeavyAirBomber(Integer.parseInt(strs[0]), Float.parseFloat(strs[1]),
+ new Color(Integer.parseInt(strs[2]), Integer.parseInt(strs[3]),Integer.parseInt(strs[4])),
+ Integer.parseInt(strs[5]), enginesType,
+ new Color(Integer.parseInt(strs[7]), Integer.parseInt(strs[8]), Integer.parseInt(strs[9])),
+ Boolean.parseBoolean(strs[10]),Boolean.parseBoolean(strs[11]), Boolean.parseBoolean(strs[12]));
+ }
+ return null;
+ }
+ public static String GetDataForSave(DrawingAirBomber drawningAirBomber)
+ {
+ var airBomber = drawningAirBomber.AirBomber;
+ var str = String.format("%s%s%s%s%s%s%s%s%s%s%s%s%s", airBomber.getSpeed(), _separatorForObject, Math.round(airBomber.getWeight()), _separatorForObject, airBomber.getBodyColor().getRed(), _separatorForObject, airBomber.getBodyColor().getGreen(), _separatorForObject, airBomber.getBodyColor().getBlue(), _separatorForObject, drawningAirBomber.drawingEngines.getNumberOfEngines(), _separatorForObject, drawningAirBomber.drawingEngines.getClass().getSimpleName());
+ if (airBomber instanceof EntityHeavyAirBomber heavyAirBomber)
+ {
+ return String.format("%s%s%s%s%s%s%s%s%s%s%s%s%s", str,_separatorForObject,heavyAirBomber.getDopColor().getRed(),_separatorForObject, heavyAirBomber.getDopColor().getGreen(), _separatorForObject, heavyAirBomber.getDopColor().getBlue(), _separatorForObject, heavyAirBomber.getBombs(), _separatorForObject, heavyAirBomber.getFuelTank(), _separatorForObject, heavyAirBomber.getTailLine());
+ }
+ else return str;
+ }
+ }
+}
diff --git a/AirBomber/src/AirBomberPackage/IDrawingObject.java b/AirBomber/src/AirBomberPackage/IDrawingObject.java
index ba533bc..104bf8c 100644
--- a/AirBomber/src/AirBomberPackage/IDrawingObject.java
+++ b/AirBomber/src/AirBomberPackage/IDrawingObject.java
@@ -37,4 +37,6 @@ public interface IDrawingObject {
///
///
float[] GetCurrentPosition();
+
+ String GetInfo();
}
diff --git a/AirBomber/src/AirBomberPackage/JFrameMapWithSetAirBombers.form b/AirBomber/src/AirBomberPackage/JFrameMapWithSetAirBombers.form
index 6a13a04..b5b3911 100644
--- a/AirBomber/src/AirBomberPackage/JFrameMapWithSetAirBombers.form
+++ b/AirBomber/src/AirBomberPackage/JFrameMapWithSetAirBombers.form
@@ -1,10 +1,58 @@