-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoard.java
41 lines (35 loc) · 1015 Bytes
/
Board.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
41
import java.util.HashMap;
public class Board
{
/**
* Constructor for objects of class Board
*/
HashMap<String,Piece> map;
public Board()
{
map = new HashMap<String, Piece>();
}
public void addPiece(int row, int col, String type)
{
map.put(String.format("%d,%d", row, col),new Piece(row, col, type));
}
public void moveUp(String pos)
{
int row = Integer.parseInt(pos.substring(0,1));
int col = Integer.parseInt(pos.substring(2,3));
Piece currentPiece = map.get(pos);
System.out.println(String.format("%d,%d",row,col));
map.put(String.format("%d,%d",(row+1),col), currentPiece);
System.out.println("post movement" + String.format("%d,%d",row,col));
map.remove(pos);
}
public Piece getPiece(String pos)
{
//System.out.println("bitch" + map.get(pos).getType());
return map.get(pos);
}
public HashMap returnMap()
{
return map;
}
}