-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grid.java
40 lines (33 loc) · 963 Bytes
/
Grid.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
public class Grid
{
private Cell[][] tabGrid;
public Grid()
{
this.tabGrid = new Cell[10][10];
for (int i =0; i<10; i++)
{
for(int j =0; j<10;j++)
{
tabGrid[i][j] = new OceanCell();
}
}
}
public Cell getCell( int rowIndex, int columnIndex)
{
return this.tabGrid[rowIndex][columnIndex];
}
public void setCell( int rowIndex, int columnIndex, ShipCell newCell)
{
this.tabGrid[rowIndex][columnIndex] = newCell ;
}
public void setTouchOcean( int rowIndex, int columnIndex)
{
TouchOceanCell newCell = new TouchOceanCell();
this.tabGrid[rowIndex][columnIndex] = newCell ;
}
public void setTouchShip( int rowIndex, int columnIndex)
{
TouchShipCell newCell = new TouchShipCell();
this.tabGrid[rowIndex][columnIndex] = newCell ;
}
}