deleted useless attributes + add new comments
This commit is contained in:
parent
b720024c15
commit
35660f9bbb
|
|
@ -3,7 +3,6 @@ package backend;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class Board {
|
public class Board {
|
||||||
private String boardString; // Represent the board's state as a string
|
|
||||||
private int line;
|
private int line;
|
||||||
private int col;
|
private int col;
|
||||||
private Piece[][] board; // 2D array to hold pieces
|
private Piece[][] board; // 2D array to hold pieces
|
||||||
|
|
@ -123,7 +122,6 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void userTouch(int x, int y) {
|
public void userTouch(int x, int y) {
|
||||||
//TODO
|
|
||||||
// Case 1: No position is selected
|
// Case 1: No position is selected
|
||||||
if (selectedPosition==null) {
|
if (selectedPosition==null) {
|
||||||
Piece clickedPiece = board[y][x];
|
Piece clickedPiece = board[y][x];
|
||||||
|
|
@ -159,6 +157,8 @@ public class Board {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void movePiece(int fromX, int fromY, int toX, int toY) {
|
public void movePiece(int fromX, int fromY, int toX, int toY) {
|
||||||
|
// Additional method: moves a piece from one position to another on the board
|
||||||
|
|
||||||
// Get the piece at the source position
|
// Get the piece at the source position
|
||||||
Piece piece = board[fromY][fromX];
|
Piece piece = board[fromY][fromX];
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,7 @@ public class Piece {
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Additional methods: updates the x or y coordinates of the piece's position on the board
|
||||||
public void setX(int x) {
|
public void setX(int x) {
|
||||||
this.X=x;
|
this.X=x;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue