Nouveau commit avec tests
This commit is contained in:
parent
d8430939f0
commit
b562328378
2 changed files with 46 additions and 4 deletions
|
|
@ -1,5 +1,8 @@
|
|||
package fr.myny.grid;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class BuildGrid {
|
||||
|
||||
private int m_dim_x;
|
||||
|
|
@ -38,22 +41,22 @@ public class BuildGrid {
|
|||
SETTERS & GETTERS
|
||||
*/
|
||||
|
||||
private int getDimX ()
|
||||
public int getDimX ()
|
||||
{
|
||||
return m_dim_x;
|
||||
}
|
||||
|
||||
private int getDimY ()
|
||||
public int getDimY ()
|
||||
{
|
||||
return m_dim_y;
|
||||
}
|
||||
|
||||
private void setDimX (int value)
|
||||
public void setDimX (int value)
|
||||
{
|
||||
m_dim_x = value;
|
||||
}
|
||||
|
||||
private void setDimY (int value)
|
||||
public void setDimY (int value)
|
||||
{
|
||||
m_dim_y = value;
|
||||
}
|
||||
|
|
@ -67,6 +70,15 @@ public class BuildGrid {
|
|||
m_grid[posX][posY] = value;
|
||||
}
|
||||
|
||||
public float getValue(int posX, int posY)
|
||||
{
|
||||
return m_grid[posX][posY];
|
||||
}
|
||||
|
||||
public float[][] getM_grid() {
|
||||
return m_grid;
|
||||
}
|
||||
|
||||
public void displayGrid ()
|
||||
{
|
||||
for (int i = 0; i < getDimX(); i++) {
|
||||
|
|
@ -87,4 +99,19 @@ public class BuildGrid {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
BuildGrid buildGrid = (BuildGrid) o;
|
||||
return m_dim_x == buildGrid.m_dim_x && m_dim_y == buildGrid.m_dim_y && Arrays.equals(m_grid, buildGrid.m_grid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = Objects.hash(m_dim_x, m_dim_y);
|
||||
result = 31 * result + Arrays.hashCode(m_grid);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in a new issue