diff --git a/src/Assignments/A1/models/Board.java b/src/Assignments/A1/models/Board.java index a5bb737..416c3ce 100644 --- a/src/Assignments/A1/models/Board.java +++ b/src/Assignments/A1/models/Board.java @@ -129,6 +129,29 @@ public class Board { return false; } + /** + * Gets the pieces in order in a single array of size 8. + * + * @precondition none + * @postcondition none + * + * @return the ordered list of values. + */ + public Piece[] getPiecesInOrder() { + Piece[] ordered = new Piece[8]; + boolean foundSpace = false; + for (Piece curr : this.pieces) { + if (curr == null) { + foundSpace = true; + } else if (!foundSpace) { + ordered[curr.getLoc()] = curr; + } else { + ordered[curr.getLoc()-1] = curr; + } + } + return ordered; + } + /** * Hashes the board by adding the pieces to an array and hashes the array. *