public class Chess { private int rookRow, rookCol; private int bishopRow, bishopCol; public Chess(int rookRow, int rookCol, int bishopRow, int bishopCol) { this.rookRow = rookRow; this.rookCol = rookCol; this.bishopRow = bishopRow; this.bishopCol = bishopCol; } public void setRookRow(int rookRow) { this.rookRow = rookRow; } public void setRookCol(int rookCol) { this.rookCol = rookCol; } public void setBishopRow(int bishopRow) { this.bishopRow = bishopRow; } public void setBishopCol(int bishopCol) { this.bishopCol = bishopCol; } // 2 public int getBiggerCol() { // do not get afraid from the syntax, it means /* if(this.bishopRow > this.rookCol) { return this.bishopCol; } else { return this.rookCol; } */ return (this.bishopCol > this.rookCol) ? this.bishopCol : this.rookCol; } // 3 public String getRookColor() { return getCellColor(this.rookRow, this.rookCol); } // 4 public boolean isRookAndBishopSameCell() { return getCellColor(this.bishopRow, this.bishopCol) == getCellColor(this.rookRow, this.rookCol); } // helper for 3 and 4 public static String getCellColor(int row, int col) { // "Black" or "White" // logic - add row and col (assuming range 1-8 inclusive). if its even then white, otherwise black. // again - do not get afraid from the syntax, its if(cond) ? return this one : (else) return thisone return ((row + col) % 2) == 0 ? "White" : "Black"; } //5 public int colDistanceBetweenRookAndBishop(){ return Math.abs(this.rookCol - this.bishopCol); } // 6 public boolean six() { if(this.rookRow != 1) { return false; } return this.rookCol > 1 && this.rookCol < 8; } // 7 public boolean rookThreatsBishop() { // assuming they are not in the same position - in this case i dont know what to do return this.rookRow == this.bishopRow || this.rookCol == this.bishopCol; } public static boolean isLegalCell(int row, int col) { return row >= 1 && row <= 8 && col >= 1 && col <= 8; } // 8 public boolean bishopThreatsRook() { int dRow = Math.abs(this.rookRow - this.bishopRow); int dCol = Math.abs(this.rookCol - this.bishopCol); return dRow == dCol; } @Override public String toString() { return "Rook: (" + rookRow + "," + rookCol + ") , Bishop: (" + bishopRow + "," + bishopCol + ")"; } public static void main(String[] args) { System.out.println("hi"); } }