Clear clear clear .c̸͙̀l̯̞̆ͥ̔͡e͖̳̠ͭ͟ă̾̚r... laba6

This commit is contained in:
Timourka 2023-11-21 12:26:47 +04:00
parent 9b48716760
commit a2314a26a6
3 changed files with 11 additions and 3 deletions

View File

@ -118,4 +118,6 @@ public class SetGeneric<T extends Object> {
} }
}; };
} }
public void clear(){ _places.clear(); }
} }

View File

@ -132,4 +132,5 @@ public class TrainsGenericCollection<T extends DrawingTrain, U extends IMoveable
i++; i++;
} }
} }
public void clear(){ _collection.clear(); }
} }

View File

@ -71,7 +71,14 @@ public class TrainsGenericStorage {
if (key == null || key.length() == 0) if (key == null || key.length() == 0)
return false; return false;
TrainsGenericCollection<DrawingTrain, DrawningObjectTrain> collection = new TrainsGenericCollection<>(_pictureWidth, _pictureHeight); TrainsGenericCollection<DrawingTrain, DrawningObjectTrain> collection;
if (_trainStorages.containsKey(key)){
collection = _trainStorages.get(key);
collection.clear();
}
else
collection = new TrainsGenericCollection<>(_pictureWidth, _pictureHeight);
List<String> trainsStrings = new ArrayList<String>(); List<String> trainsStrings = new ArrayList<String>();
s = reader.readLine(); s = reader.readLine();
@ -87,8 +94,6 @@ public class TrainsGenericStorage {
return false; return false;
} }
if (_trainStorages.containsKey(key))
_trainStorages.remove(key);
_trainStorages.put(key, collection); _trainStorages.put(key, collection);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();