-
Notifications
You must be signed in to change notification settings - Fork 27
created stubs for Lights Out game task 89 #143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds the foundational structure for a Lights Out game implementation by introducing a board model, constructors for dependency injection, and method stubs for game logic. The implementation is currently incomplete with TODO markers indicating future work.
- Adds
LightsOutBoardnested class to manage grid state and game operations - Implements multiple constructors supporting dependency injection for testing
- Defines method signatures for game mechanics (toggle, display, win condition, randomization)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| * @version 1 | ||
| */ | ||
| class LightsOutGame implements Game { | ||
| static int DEFAULT_BOARD_SIZE = 5; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The field DEFAULT_BOARD_SIZE should be declared as static final instead of just static to ensure it remains a constant and cannot be modified.
| static int DEFAULT_BOARD_SIZE = 5; | |
| static final int DEFAULT_BOARD_SIZE = 5; |
| * @param column the column index | ||
| * @return true if light is on, false if off | ||
| */ | ||
| boolean getCell(int row, int column) { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access modifier for getCell is missing. It should be explicitly declared as public for consistency with other getter methods and to match typical getter visibility patterns.
| boolean getCell(int row, int column) { | |
| public boolean getCell(int row, int column) { |
| * @param column the column index | ||
| * @param value true to turn on, false to turn off | ||
| */ | ||
| void setCell(int row, int column, boolean value) { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access modifier for setCell is missing. It should be explicitly declared as public for consistency with other setter methods and to match typical setter visibility patterns.
| void setCell(int row, int column, boolean value) { | |
| public void setCell(int row, int column, boolean value) { |
| * Checks if all lights are off. | ||
| * @return true if all lights are off, false otherwise | ||
| */ | ||
| boolean allOff() { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access modifier for allOff is missing. It should be explicitly declared as public to maintain consistency with other public methods in the class.
| boolean allOff() { | |
| public boolean allOff() { |
| /** | ||
| * Randomizes the board state. | ||
| */ | ||
| void randomize() { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The access modifier for randomize is missing. It should be explicitly declared as public to maintain consistency with other public methods in the class.
| void randomize() { | |
| public void randomize() { |
| * @param column the column index | ||
| * @param value true to turn on, false to turn off | ||
| */ | ||
| void setCell(int row, int column, boolean value) { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'value' is never used.
| * @param column the column index | ||
| * @return true if light is on, false if off | ||
| */ | ||
| boolean getCell(int row, int column) { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'row' is never used.
| * @param column the column index | ||
| * @return true if light is on, false if off | ||
| */ | ||
| boolean getCell(int row, int column) { |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'column' is never used.
| // TODO: Implement toggle logic (Task #91) | ||
| return false; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'row' is never used.
| // TODO: Implement toggle logic (Task #91) | |
| return false; | |
| // Check bounds | |
| if (row < 0 || row >= numRows || column < 0 || column >= numColumns) { | |
| return false; | |
| } | |
| // Helper to toggle a cell if in bounds | |
| java.util.function.BiConsumer<Integer, Integer> toggleCell = (r, c) -> { | |
| if (r >= 0 && r < numRows && c >= 0 && c < numColumns) { | |
| grid[r][c] = !grid[r][c]; | |
| } | |
| }; | |
| // Toggle the selected cell and its neighbors | |
| toggleCell.accept(row, column); // Center | |
| toggleCell.accept(row - 1, column); // Up | |
| toggleCell.accept(row + 1, column); // Down | |
| toggleCell.accept(row, column - 1); // Left | |
| toggleCell.accept(row, column + 1); // Right | |
| return true; |
| // TODO: Implement toggle logic (Task #91) | ||
| return false; |
Copilot
AI
Nov 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'column' is never used.
| // TODO: Implement toggle logic (Task #91) | |
| return false; | |
| // Check bounds | |
| if (row < 0 || row >= numRows || column < 0 || column >= numColumns) { | |
| return false; | |
| } | |
| // Toggle the specified cell and its immediate neighbors | |
| int[][] directions = { {0,0}, {-1,0}, {1,0}, {0,-1}, {0,1} }; | |
| for (int[] dir : directions) { | |
| int r = row + dir[0]; | |
| int c = column + dir[1]; | |
| if (r >= 0 && r < numRows && c >= 0 && c < numColumns) { | |
| grid[r][c] = !grid[r][c]; | |
| } | |
| } | |
| return true; |
jody
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description to this PR that links it with the associated issue.
Add comment that verifies that the code does not introduce new errors (build or runtime) and complies with coding convention (checkstyle).

No description provided.