diff --git a/src/Assignments/A1/models/Piece.java b/src/Assignments/A1/models/Piece.java index 07389d3..36df2af 100644 --- a/src/Assignments/A1/models/Piece.java +++ b/src/Assignments/A1/models/Piece.java @@ -25,11 +25,26 @@ public class Piece { if (value < 1 || value > 8) { throw new IllegalArgumentException("The piece value is not valid. Valid Range: 1 <= Value <= 8"); } - this.setLoc(loc); this.value = value; } + /** + * Creates a new piece from an existing piece. + * + * @precondition piece != null + * @postcondition a copied piece is created. + * + * @param piece the piece being copied + */ + public Piece(Piece piece) { + if (piece == null) { + throw new IllegalArgumentException("The piece cannot be null."); + } + this.loc = piece.getLoc(); + this.value = piece.getValue(); + } + /** * Moves the piece to a new location. *