From 441001a425ab693f50e52610d7f7f1935bbeb60a Mon Sep 17 00:00:00 2001 From: Inohara Date: Fri, 16 Dec 2022 12:06:53 +0400 Subject: [PATCH] =?UTF-8?q?7=20=D0=BB=D0=B0=D0=B1=D0=BE=D1=80=D0=B0=D1=82?= =?UTF-8?q?=D0=BE=D1=80=D0=BD=D0=B0=D1=8F(=D0=B1=D0=B5=D0=B7=20=D0=BB?= =?UTF-8?q?=D0=BE=D0=B3=D0=B3=D0=BE=D0=B2)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/AircraftCarrier_Hard.iml | 18 ++++++++++++ messages | 8 ------ src/FormMapWithSetWarships.form | 2 +- src/FormMapWithSetWarships.java | 13 ++++++--- src/Main.java | 4 ++- src/MapWithSetWarshipsGeneric.java | 7 +++-- src/SetWarshipsGeneric.java | 2 +- src/log4j.xml | 46 ++++++++++++++++++------------ 8 files changed, 63 insertions(+), 37 deletions(-) delete mode 100644 messages diff --git a/.idea/AircraftCarrier_Hard.iml b/.idea/AircraftCarrier_Hard.iml index 43191f2..5c48835 100644 --- a/.idea/AircraftCarrier_Hard.iml +++ b/.idea/AircraftCarrier_Hard.iml @@ -7,6 +7,24 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/messages b/messages deleted file mode 100644 index 711e221..0000000 --- a/messages +++ /dev/null @@ -1,8 +0,0 @@ -2022-12-14 00:20:19 INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 -2022-12-14 00:20:19 INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 - INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 2022-12-14 - INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 2022-12-14 - INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 2022-12-14 - INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 2022-12-14 - INFO FormMapWithSetTractorsGeneric:195 - Переход на карту: 1 14-12-2022 - INFO FormMapWithSetTractorsGeneric:228 - Добавлена карта: 1 14-12-2022 diff --git a/src/FormMapWithSetWarships.form b/src/FormMapWithSetWarships.form index d727893..a3e5af9 100644 --- a/src/FormMapWithSetWarships.form +++ b/src/FormMapWithSetWarships.form @@ -3,7 +3,7 @@ - + diff --git a/src/FormMapWithSetWarships.java b/src/FormMapWithSetWarships.java index 52b1b82..68f7a69 100644 --- a/src/FormMapWithSetWarships.java +++ b/src/FormMapWithSetWarships.java @@ -7,7 +7,7 @@ import java.io.File; import java.util.HashMap; import java.util.function.Consumer; -import org.apache.log4j.*; +import org.apache.log4j.Logger; public class FormMapWithSetWarships extends JFrame{ private JPanel mainPanel; private JPanel PictureBox; @@ -44,6 +44,11 @@ public class FormMapWithSetWarships extends JFrame{ private Logger _logger; + public FormMapWithSetWarships(Logger logger){ + this(); + this._logger=logger;; + } + public FormMapWithSetWarships(){ InitializeComponent(); } @@ -74,10 +79,10 @@ public class FormMapWithSetWarships extends JFrame{ } private void InitializeComponent(){ - _logger = Logger.getLogger("FormMapWithSetTractorsGeneric"); + setContentPane(mainPanel); setTitle("Warship"); - setSize(935, 693); + setSize(554, 548); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setVisible(true); @@ -192,7 +197,7 @@ public class FormMapWithSetWarships extends JFrame{ if(ListBoxMaps.getSelectedIndex() == -1) return; bufferedImage = _mapsCollection.get(ListBoxMaps.getSelectedValue().toString()).ShowSet(); - _logger.log(Level.INFO,"Переход на карту: " + ListBoxMaps.getSelectedValue().toString()); + _logger.info("Переход на карту "+ListBoxMaps.getSelectedValue()); repaint(); }); diff --git a/src/Main.java b/src/Main.java index 17772ee..30cfb47 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,5 +1,7 @@ + +import org.apache.log4j.*; public class Main { public static void main(String[] args) { - new FormMapWithSetWarships(); + new FormMapWithSetWarships(LogManager.getLogger(Main.class)); } } diff --git a/src/MapWithSetWarshipsGeneric.java b/src/MapWithSetWarshipsGeneric.java index 61d7031..2e54a1e 100644 --- a/src/MapWithSetWarshipsGeneric.java +++ b/src/MapWithSetWarshipsGeneric.java @@ -116,14 +116,15 @@ public class MapWithSetWarshipsGeneric implements Iterable{ public int Insert(T warship, int position) { - if (position < 0 || position >= _maxCount) + if (position < 0 || position >= _maxCount || getCount() >= _maxCount) throw new StorageOverflowException(_maxCount); _places.add(position, warship); return position; diff --git a/src/log4j.xml b/src/log4j.xml index b7708ff..782b52b 100644 --- a/src/log4j.xml +++ b/src/log4j.xml @@ -1,19 +1,27 @@ - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + [%-5level] %msg (%d{dd.MM.yyyy})%n + + + + + + + + [%-5level] %msg (%d{dd.MM.yyyy})%n + + + + + + + + + + + + \ No newline at end of file