From f1b87ec380d0cbfdcec10d3f322c543ebde37c3d Mon Sep 17 00:00:00 2001 From: Programmist73 Date: Mon, 5 Dec 2022 20:50:51 +0400 Subject: [PATCH] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B5=20=D1=81=D0=BE=D1=80=D1=82=D0=B8=D1=80?= =?UTF-8?q?=D0=BE=D0=B2=D0=BE=D0=BA=20=D0=B2=208-=D0=B9=20=D0=BB=D0=B0?= =?UTF-8?q?=D0=B1=D0=BE=D1=80=D0=B0=D1=82=D0=BE=D1=80=D0=BD=D0=BE=D0=B9.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Project/loginfo.log | 9 +++++ Project/logwarn.log | 1 + Project/src/DrawingAirbus.java | 2 +- Project/src/DrawingPlane.java | 16 +++++++++ Project/src/FormPlane.java | 2 +- Project/src/PlaneCompareByColor.java | 50 ++++++++++++++++++---------- Project/src/PlaneCompareByType.java | 40 +++++++++++----------- 7 files changed, 80 insertions(+), 40 deletions(-) diff --git a/Project/loginfo.log b/Project/loginfo.log index 2f446f9..e3ddd53 100644 --- a/Project/loginfo.log +++ b/Project/loginfo.log @@ -3,3 +3,12 @@ INFO FormMapWithSetPlanesGeneric:191 - Осуществлён переход н INFO FormMapWithSetPlanesGeneric:157 - Добавлена карта 454 02-12-2022 INFO FormMapWithSetPlanesGeneric:191 - Осуществлён переход на карту под названием 454 02-12-2022 INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 03-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022 +INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@7d175d9c 04-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022 +INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@65494a28 04-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022 +INFO FormMapWithSetPlanesGeneric:239 - Добавлен объект: DrawningObjectPlane@4c9c0121 04-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 04-12-2022 +INFO FormMapWithSetPlanesGeneric:193 - Осуществлён переход на карту под названием 123 05-12-2022 diff --git a/Project/logwarn.log b/Project/logwarn.log index 64f7259..25705e5 100644 --- a/Project/logwarn.log +++ b/Project/logwarn.log @@ -1,2 +1,3 @@ WARN FormMapWithSetPlanesGenericAdmin:304 - Ошибка удаления: Не найден объект по позиции 1 02-12-2022 WARN FormMapWithSetPlanesGenericAdmin:304 - Ошибка удаления: Не найден объект по позиции 0 02-12-2022 +ERROR FormMapWithSetPlanesGenericAdmin:493 - Ошибка загрузки: Формат данных в файле неправильный 04-12-2022 diff --git a/Project/src/DrawingAirbus.java b/Project/src/DrawingAirbus.java index 5d8009b..005cddc 100644 --- a/Project/src/DrawingAirbus.java +++ b/Project/src/DrawingAirbus.java @@ -73,4 +73,4 @@ public class DrawingAirbus extends DrawingPlane super.repaint(); } -} +} \ No newline at end of file diff --git a/Project/src/DrawingPlane.java b/Project/src/DrawingPlane.java index 073e2a6..a7b692e 100644 --- a/Project/src/DrawingPlane.java +++ b/Project/src/DrawingPlane.java @@ -1,6 +1,7 @@ import java.awt.*; import javax.swing.*; import java.awt.Color; +import java.util.Iterator; import java.util.Random; public class DrawingPlane extends JPanel @@ -225,4 +226,19 @@ public class DrawingPlane extends JPanel { return new float[]{_startPosX, _startPosY, _startPosX + _airbusWidth, _startPosY + _airbusHeight}; } +/* + @Override + public Iterator iterator() { + return null; + } + + @Override + public boolean hasNext() { + return false; + } + + @Override + public Object next() { + return null; + }*/ } diff --git a/Project/src/FormPlane.java b/Project/src/FormPlane.java index 5700e0a..3db961e 100644 --- a/Project/src/FormPlane.java +++ b/Project/src/FormPlane.java @@ -239,4 +239,4 @@ public class FormPlane extends JDialog } }); } -} +} \ No newline at end of file diff --git a/Project/src/PlaneCompareByColor.java b/Project/src/PlaneCompareByColor.java index 7211b9f..e3ced06 100644 --- a/Project/src/PlaneCompareByColor.java +++ b/Project/src/PlaneCompareByColor.java @@ -16,7 +16,7 @@ public class PlaneCompareByColor implements Comparator return 1; } - if (x != null && y != null) + if (x != null && y == null) { return -1; } @@ -36,31 +36,45 @@ public class PlaneCompareByColor implements Comparator if (xPlane != null && yPlane == null) { - return 1; + return -1; } - if(xPlane.GetPlane().Plane.GetSpeed() != yPlane.GetPlane().Plane.GetSpeed()) - { - return 1; - } + var xEntityPlane = xPlane.GetPlane().Plane; + var yEntityPlane = yPlane.GetPlane().Plane; - if (xPlane.GetPlane().Plane.GetWeight() != yPlane.GetPlane().Plane.GetWeight()) - { - return 1; - } + Integer colorCompare1 = xEntityPlane.GetColor().getRGB(); + Integer colorCompare2 = yEntityPlane.GetColor().getRGB(); + var colorCompare = colorCompare1.compareTo(colorCompare2); - var xEntity = xPlane.GetPlane().Plane; - var yEntity = yPlane.GetPlane().Plane; - var colorCompare = xEntity.GetColor().toString().compareTo(yEntity.GetColor().toString()); - - if (colorCompare != 0 || xEntity instanceof EntityAirbus || yEntity instanceof EntityAirbus) + if (colorCompare != 0) { return colorCompare; } - EntityAirbus xEntityAirbus = (EntityAirbus)xEntity; - EntityAirbus yEntityAirbus = (EntityAirbus)yEntity; + if (xEntityPlane instanceof EntityAirbus xAirbus && yEntityPlane instanceof EntityAirbus yAirbus) + { + Integer dopColorCompare1 = xAirbus.AddColor().getRGB(); + Integer dopColorCompare2 = yAirbus.AddColor().getRGB(); + var addColorCompare = dopColorCompare1.compareTo(dopColorCompare2); - return xEntityAirbus.AddColor().toString().compareTo(yEntityAirbus.AddColor().toString()); + if(addColorCompare != 0) + { + return addColorCompare; + } + } + + Integer speedCompare1 = xPlane.GetPlane().Plane.GetSpeed(); + Integer speedCompare2 = yPlane.GetPlane().Plane.GetSpeed(); + var speedCompare = speedCompare1.compareTo(speedCompare2); + + if(speedCompare != 0) + { + return speedCompare; + } + + Float weightCompare1 = xPlane.GetPlane().Plane.GetWeight(); + Float weightCompare2 = yPlane.GetPlane().Plane.GetWeight(); + + return weightCompare1.compareTo(weightCompare2); } } diff --git a/Project/src/PlaneCompareByType.java b/Project/src/PlaneCompareByType.java index 77c9a4d..6f6eb79 100644 --- a/Project/src/PlaneCompareByType.java +++ b/Project/src/PlaneCompareByType.java @@ -15,7 +15,7 @@ public class PlaneCompareByType implements Comparator return 1; } - if (x != null && y != null) + if (x != null && y == null) { return -1; } @@ -35,31 +35,31 @@ public class PlaneCompareByType implements Comparator if (xPlane != null && yPlane == null) { + return -1; + } + + if(xPlane.GetPlane().getClass().getSimpleName() != yPlane.GetPlane().getClass().getSimpleName()) + { + if(xPlane.GetPlane().getClass().getSimpleName() == "DrawingPlane") + { + return -1; + } + return 1; } - if(xPlane.GetPlane().Plane.GetSpeed() != yPlane.GetPlane().Plane.GetSpeed()) + Integer speedCompare1 = xPlane.GetPlane().Plane.GetSpeed(); + Integer speedCompare2 = yPlane.GetPlane().Plane.GetSpeed(); + var speedCompare = speedCompare1.compareTo(speedCompare2); + + if(speedCompare != 0) { - return 1; + return speedCompare; } - if (xPlane.GetPlane().Plane.GetWeight() != yPlane.GetPlane().Plane.GetWeight()) - { - return 1; - } + Float weightCompare1 = xPlane.GetPlane().Plane.GetWeight(); + Float weightCompare2 = yPlane.GetPlane().Plane.GetWeight(); - var xEntity = xPlane.GetPlane().Plane; - var yEntity = yPlane.GetPlane().Plane; - var colorCompare = xEntity.CorpusColor.toString().compareTo(yEntity.CorpusColor.toString()); - - if (colorCompare != 0 || xEntity instanceof EntityAirbus || yEntity instanceof EntityAirbus yEntityAirbus) - { - return colorCompare; - } - - EntityAirbus xEntityAirbus = (EntityAirbus) xEntity; - EntityAirbus yEntityAirbus = (EntityAirbus) yEntity; - - return xEntityAirbus.AddColor().toString().compareTo(yEntityAirbus.AddColor().toString()); + return weightCompare1.compareTo(weightCompare2); } }