2. Перопределение метода equals у AbstractMap
This commit is contained in:
parent
c20e69866e
commit
b15fd30fb1
@ -185,4 +185,42 @@ public abstract class AbstractMap {
|
||||
protected abstract void GenerateMap();
|
||||
protected abstract void DrawRoadPart(Graphics2D g, int i, int j);
|
||||
protected abstract void DrawBarrierPart(Graphics2D g, int i, int j);
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (other == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
var otherMap = (AbstractMap)other;
|
||||
if (otherMap == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (width != otherMap.width)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (height != otherMap.height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (size_x != otherMap.size_x)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (size_y != otherMap.size_y)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < map.length; i++)
|
||||
{
|
||||
for (int j = 0; j < map[0].length; j++)
|
||||
{
|
||||
if (map[i][j] != otherMap.map[i][j])
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user