We provide to you a list of Java expressions that depend on: • this.x : the x coordinate of the piece to move this.y : the y coordinate of the piece to move • destX : the x-coordinate of the square to move to • destY : the y-coordinate of the square to move to In order to implement your own logic, you can also use this variable in your methods:
We provide to you a list of Java expressions that depend on: • this.x : the x coordinate of the piece to move this.y : the y coordinate of the piece to move • destX : the x-coordinate of the square to move to • destY : the y-coordinate of the square to move to In order to implement your own logic, you can also use this variable in your methods:
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Implement the following method to move a pawn piece in chess:
public class Pawn extends Piece {
public Pawn(int x, int y, Side side, Board board) {
super(x, y, side, board);
}
@Override
public boolean canMove(int destX, int destY) {
if((destX > 7 || destY > 7 ) || (destX < 0 ||destY < 0)) {
return false;
}else {

Transcribed Image Text:We provide to you a list of Java expressions that depend on:
• this.x : the x coordinate of the piece to move
X
this.y : the y coordinate of the piece to move
destX : the x-coordinate of the square to move to
• destY : the y-coordinate of the square to move to
In order to implement your own logic, you can also use this variable in your methods:
• Board b : the board on which the piece is moving
You are intended to use these expressions to implement canMove() for the Piece class.

Transcribed Image Text:Pawn
The pawn has a few special and unusual rules for how it can move. First, the pawn normally can advance
forward one square per turn. However, if the pawn has not yet moved (it is on its starting square) then it is
allowed to move forward either one or two squares. In the case of a two square move, it is not allowed to
"hop" over other pieces; recall only the knight can hop over pieces.
Another special rule is that if there exists a piece directly in front of the pawn, then the pawn cannot
move forward. In particular, if it is an opposing player's piece, then the pawn cannot capture that piece.
So how does the pawn capture other pieces? There is only one way: if an enemy piece exists one square
diagonally forward from the pawn (one square forward and then one square left or right) then the pawn
may capture it and move to that diagonal square. We emphasize that the pawn must always move forward,
either straight forward to an empty square, or diagonally to capture an enemy piece.
You are responsible for implementing all the above described behaviours for all pieces.
Expert Solution

This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps

Similar questions
Recommended textbooks for you

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON

Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science

Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning

Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning

Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education

Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY