Commit f2b5d1a6 authored by 9611046's avatar 9611046

documentation for Square class

parent db8d2b79
......@@ -18,6 +18,11 @@ public class Square extends JButton {
private JLabel image;
private boolean possibleSquare = false;
/**
*
* @param x x coordinate of square
* @param y y coordinate of square
*/
public Square(int x, int y){
this.x=x;
this.y = y;
......@@ -25,6 +30,10 @@ public class Square extends JButton {
}
/**
*
* @param piece put a piece on a chess square
*/
public void setPiece(Piece piece) {
this.piece = piece;
hasPiece = true;
......@@ -33,32 +42,58 @@ public class Square extends JButton {
this.add(image);
}
/**
* selects a square by redrawing its line border
*/
public void selectSquare()
{
this.setBorder(BorderFactory.createLineBorder(Color.red,6));
this.isSelected=true;
}
/**
* deselects a square by deleting its red border line
*/
public void cancleSelection(){
this.isSelected=true;
this.isSelected=false;
this.setBorder(null);
}
/**
* makes a square possible for moving a piece by making its border line green
*/
public void makePossible(){
this.setBorder(BorderFactory.createLineBorder(Color.green,6));
this.possibleSquare = true;
}
/**
* removes a piece of a square
*/
public void removePiece(){
this.piece = null;
this.remove(image);
}
/**
*
* @return true if this square has a piece
*/
public boolean hasPiece() {
return hasPiece;
}
/**
* @return true if square is possible for moving a piece
*/
public boolean isPossibleSquare() {
return possibleSquare;
}
/**
*
* @return the piece of a square
*/
public Piece getPiece(){
return piece;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment