Polevoy S.V Lab_work7 #7

Closed
ChipsEater wants to merge 9 commits from LabWork07 into LabWork06
Showing only changes of commit c9001dec40 - Show all commits

View File

@ -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<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapsStorage[elements[0]].LoadData(elements[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
return true;
}
}
}