From c9001dec409659d53242949d0e496ba6c57bbf0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D0=B5=D1=80=D0=B3=D0=B5=D0=B9=20=D0=9F=D0=BE=D0=BB?= =?UTF-8?q?=D0=B5=D0=B2=D0=BE=D0=B9?= Date: Tue, 8 Nov 2022 00:45:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=BE=D0=B1=D1=80=D0=B0?= =?UTF-8?q?=D0=B7=D0=BE=D0=B2=D0=B0=D0=BD=20=D0=BA=D0=BB=D0=B0=D1=81=D1=81?= =?UTF-8?q?=20MapsCollection=20-=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=BE=20=D0=B2=D1=8B=D0=B1=D1=80=D0=B0=D1=81=D1=8B?= =?UTF-8?q?=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B8=D1=81=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SelfPropelledArtilleryUnit/MapsCollection.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/SelfPropelledArtilleryUnit/MapsCollection.cs b/SelfPropelledArtilleryUnit/MapsCollection.cs index 8e657f8..f0c5483 100644 --- a/SelfPropelledArtilleryUnit/MapsCollection.cs +++ b/SelfPropelledArtilleryUnit/MapsCollection.cs @@ -49,7 +49,7 @@ namespace Artilleries } } - public bool SaveData(string filename) + public void SaveData(string filename) { if (File.Exists(filename)) { @@ -65,15 +65,13 @@ namespace Artilleries sw.WriteLine($"{storage.Key}{separatorDict}{storage.Value.GetData(separatorDict, separatorData)}"); } } - - return true; } - public bool LoadData(string filename) + public void LoadData(string filename) { if (!File.Exists(filename)) { - return false; + throw new FileNotFoundException("Файл не найден"); } using (FileStream fs = new FileStream(filename, FileMode.Open)) @@ -83,7 +81,7 @@ namespace Artilleries if (current_line == null || !current_line.Contains("MapsCollection")) { - return false; + throw new FileFormatException("Неверный формат файла"); } _mapsStorage.Clear(); @@ -105,8 +103,6 @@ namespace Artilleries _mapsStorage.Add(elements[0], new MapWithSetArtilleriesGeneric(_pictureWidth, _pictureHeight, map)); _mapsStorage[elements[0]].LoadData(elements[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries)); } - - return true; } } }