A class Board is being developed to represent the current state of a game that i
ID: 3643412 • Letter: A
Question
A class Board is being developed to represent the current state of a game that is played on a two-dimensional grid of cells where each cell can be empty or occupied by a piece for one of the players. (For example, tic-tac-toe, othello, chinese-checkers, go) The grid has a fixed size. All player pieces are the same, except for which player they belong to (for example, black or white). Assume the class Location stores row and column indices and implements the Comparable interface so that locations are in row-major order (a location with a smaller row comes before one with a greater row, if the rows are the same the location with the smaller column comes first). Consider the following data structures for class Board.I. One ordered ArrayList<Location> that holds all the occupied locations.
II. An ArrayList<Location> for each player, holding all the locations of that player's pieces.
III. An ArrayList<Pair>, where Pair is a class that has a Location and a reference to a Player, with accessor methods for each.
Which of these data structure could be used to implement Board so that it correctly determines the state of the game?
A.) I only
B.) III only
C.) I and III only
D.) II and III only
E.) I, II, and III
Explanation / Answer
Answer is C
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.