-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathActionMove.java
More file actions
33 lines (30 loc) · 1.2 KB
/
ActionMove.java
File metadata and controls
33 lines (30 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/**
* @author John Henry Cooper
* @version 15.0.2
* Contains a constructor for an ActionMove object as well as an overridden preformAction method that carries out an
* a move command
*/
public class ActionMove extends Action{
/**
@param fromRow - row inxed of attacking piece
@param fromColumn - column index of attacking piece
@param toRow - row inxed of where attacking piece will attack
@param toColumn - column index of where attacking piece will attack
calls it's super constructor and passes values to create an ActionMove object
*/
public ActionMove(GameS22 game, int fromRow, int fromColumn, int toRow, int toColumn){
super(game, fromRow, fromColumn, toRow, toColumn);
}
/**
* calls the piece's speak method, removes it from its square and moves it to the to square.
*/
@Override
public void performAction() {
BoardSquare[][] boardSquares = game.getBoardSquares();
Piece piece1 = boardSquares[fromRow][fromColumn].getPiece();
piece1.speak();
boardSquares[fromRow][fromColumn].removePiece();
boardSquares[toRow][toColumn].setPiece(piece1);
game.changeTurn();
}
}