Sorokin_P.V. Lab Work 6 #6

Merged
eegov merged 7 commits from LabWork06 into LabWork05 2022-11-11 09:01:35 +04:00
Showing only changes of commit 401fa5cbd7 - Show all commits

View File

@ -74,43 +74,32 @@ namespace Liner
string bufferTextFromFile = "";
using (StreamReader sr = new(filename))
{
bool isFirst = true;
string str;
string str = sr.ReadLine();
if (!str.Contains("MapsCollection"))
{
return false;
}
_mapStorages.Clear();
while ((str = sr.ReadLine()) != null)
{
if (isFirst)
var tempElem = str.Split(separatorDict);
AbstractMap map = null;
switch (tempElem[1])
{
if (!str.Contains("MapsCollection"))
{
return false;
}
else
{
_mapStorages.Clear();
}
isFirst = false;
}
else
{
var tempElem = str.Split(separatorDict);
AbstractMap map = null;
switch (tempElem[1])
{
case "SimpleMap":
map = new SimpleMap();
break;
case "SeaMap":
map = new SeaMap();
break;
case "SwampMap":
map = new SwampMap();
break;
case "SimpleMap":
map = new SimpleMap();
break;
case "SeaMap":
map = new SeaMap();
break;
case "SwampMap":
map = new SwampMap();
break;
}
_mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
}
_mapStorages.Add(tempElem[0], new MapWithSetShipsGeneric<IDrawingObject, AbstractMap>(_pictureWidth, _pictureHeight, map));
_mapStorages[tempElem[0]].LoadData(tempElem[2].Split(separatorData, StringSplitOptions.RemoveEmptyEntries));
}
}
return true;
}