Commit 72f9a332 authored by 9611046's avatar 9611046

Documentation

parent d81eeeb2
......@@ -255,12 +255,28 @@ public class Main extends JFrame implements MouseListener {
Mainboard = new Main();
}
private void changeTurn() {
/**
* performs changing turn of players
*/
public void changeTurn() {
if (whosTurn.equals("w")) whosTurn = "b";
else whosTurn = "w";
}
/*
public boolean checkmateCheck(Square [][] chessBoardSquares){
}
*/
/**
*
* @param color is the player color
* @param board is current board
* @return true if the player king piece is checked
*/
private boolean isChecked(String color, Square[][] board) {
if (color.equals("w")) return wk.isChecked(board);
else if (color.equals("b")) return bk.isChecked(board);
......
......@@ -5,13 +5,33 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
*Bishop class show the Bishop's moves that moves and set its ID imagePath and color
*/
public class Bishop extends Piece {
//constructor
/**
*
* @param ID set ID of bishop
* @param imagePath set image of bishop
* @param color set color of bishop
*/
public Bishop(String ID, String imagePath, String color) {
setPieceId(ID);
setImage(imagePath);
setPieceColor(color);
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of bishop in board
* @param y is the y of bishop in board
* @return arraylist of next possible squares of bishop
*/
public ArrayList<Square> move(Square[][] boardSquares, int x, int y) {
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
ArrayList<Square> possibleSquares=new ArrayList<>();
......
......@@ -5,8 +5,19 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
* *King class show the King's moves that moves and set its ID imagePath and color
*/
public class King extends Piece {
private int x,y;
/**
*
* @param ID set ID of king
* @param imagePath set image king
* @param color set color of king
*/
public King(String ID,String imagePath,String color,int x,int y)
{
this.x=x;
......@@ -16,27 +27,51 @@ public class King extends Piece {
setPieceColor(color);
}
public King() {
}
/**
*
* @param x set x coordinate of king
*/
public void setx(int x)
{
this.x=x;
}
/**
*
* @param y set y coordinate of a king
*/
public void sety(int y)
{
this.y=y;
}
/**
*
* @return x coordinate of king
*/
public int getx()
{
return x;
}
/**
*
* @return y coordinate of king
*/
public int gety()
{
return y;
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of king in board
* @param y is the y of king in board
* @return arraylist of next possible squares of king
*/
public ArrayList<Square> move(Square[][] squares, int x, int y){
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
ArrayList<Square> possibleSquares=new ArrayList<>();
......@@ -53,6 +88,11 @@ public class King extends Piece {
return possibleSquares;
}
/**
*
* @param squares current situation of a board
* @return true if king is checked
*/
public boolean isChecked(Square [][] squares){
//Checking for attack from left,right,up and down
for(int i=x+1;i<8;i++)
......
......@@ -4,14 +4,30 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
*Bishop class show the Knight's moves that moves and set its ID imagePath and color
*/
public class Knight extends Piece {
/**
*
* @param ID set ID of Knight
* @param imagePath set image of Knight
* @param color set color of Knight
*/
public Knight(String ID, String imagePath, String color) {
setPieceId(ID);
setImage(imagePath);
setPieceColor(color);
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of Knight in board
* @param y is the y of Knight in board
* @return arraylist of next possible squares of Knight
*/
public ArrayList<Square> move(Square [][] boardSquares, int x, int y) {
ArrayList<Square> possibleSquares=new ArrayList<>();
//possibleSquares.clear();
......
......@@ -4,10 +4,19 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
* *King class show the Pawn's moves that moves and set its ID imagePath and color
*/
public class Pawn extends Piece {
/**
*
* @param ID set ID of Pawn
* @param imagePath set image of Pawn
* @param color set color of Pawn
*/
public Pawn(String ID,String imagePath,String color){
setPieceId(ID);
setImage( imagePath);
......@@ -15,6 +24,12 @@ public class Pawn extends Piece {
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of Pawn in board
* @param y is the y of Pawn in board
* @return arraylist of next possible squares of Pawn
*/
public ArrayList<Square> move(Square [][] boardSquares, int x, int y) {
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
// possibleSquares.clear();
......
......@@ -5,7 +5,18 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
* *King class show the Queen's moves that moves and set its ID imagePath and color
*/
public class Queen extends Piece {
/**
*
* @param ID set ID of Queen
* @param imagePath set image of Queen
* @param color set color of Queen
*/
public Queen(String ID,String imagePath,String color){
setPieceId(ID);
......@@ -13,6 +24,13 @@ public class Queen extends Piece {
setPieceColor(color);
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of Queen in board
* @param y is the y of Queen in board
* @return arraylist of next possible squares of Queen
*/
public ArrayList<Square> move(Square [][] boardSquares, int x, int y) {
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
ArrayList<Square> possibleSquares=new ArrayList<>();
......
......@@ -5,13 +5,29 @@ import game.Square;
import java.util.ArrayList;
import java.util.Iterator;
/**
* @author Newsha Shahbodaghkhan
* *King class show the Rook's moves that moves and set its ID imagePath and color
*/
public class Rook extends Piece {
/**
*
* @param ID set ID of Rook
* @param imagePath set image of Rook
* @param color set color of Rook
*/
public Rook(String ID,String imagePath,String color){
setPieceId(ID);
setImage( imagePath);
setPieceColor(color);
}
@Override
/**
* @param boardSquare is the current board situation
* @param x is the x of Rook in board
* @param y is the y of Rook in board
* @return arraylist of next possible squares of Rook
*/
public ArrayList<Square> move(Square [][] boardSquares, int x, int y){
//The java.util.ArrayList.clear() method removes all of the elements from this list.The list will be empty after this call returns.
ArrayList<Square> possibleSquares=new ArrayList<>();
......
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