Complete the SudokuBoard.java class. This class draws the basic board for the Su
ID: 674952 • Letter: C
Question
Complete the SudokuBoard.java class. This class draws the basic board for the Sudoku game, indicating the individual cells and the regions. (The rows and columns don't need any specific indication, being obvious if the layout is good.)
Add comments to SudokuBase. This includes documentation support, JavaDoc comments. There should be no substantive code changes to SudokuBase; you are only adding comments. This is to insure that you understand the basic functionality you are working with.
Implement the SelectedCell.java interface. This interface supports having an "active" cell in the Sudoku Board.
The primary task for this assignment is creating an object that will display the Sudoku board. This display shall render the cells in a square grid. The different regions of the board shall be indicated by a difference in background color. This is a common way to differentiate the regions, as seen in the Background section of the project overview. Use Color.white and Gainsboro for the different region backgrounds. Gainsboro is one of the named colors for web programming. It is #DCDCDC, or rgb(220, 220, 220).
The constructor for SudokuBoard takes a SudokuBase as a parameter. From the SudokuBase object, the size and arrangement of the cells and regions can be determined using the public methods getRows and getColumns. Of course, you can also use the getSize method. The SudokuBoard constructor shall set the preferred size of the SudokuBoard component based on the size of the board. The cell sizes are specified below.
To simplify the display, fix the size of the individual cells to 50x50. Drawing borders around the cells will help make the rows and columns easy to see. For example, if there is a one-pixel wide border one pixel in from the edge of the cells, the edges are clean. (The alternation of two-pixel wide borders between cells and one-pixel wide borders at the edges occurs when cell borders abut. This is unattractive.) Notice that this means that there is a two-pixel wide margin between the cells. The board can be completed by drawing another line around the entire board such that there is a two-pixel wide border at the edges as well.
the last two things to do are
keyboard support for changing the selected cell
the algorithm to change between two descriptions of a cells location: row/column and region/ordinal
CODE
__________________________________________
SUDOKU BOARD
The SudokuBoard class shall have methods that will get and set the location of the selected cell. To support the selected cell, SudokuBoard shall implement the SelectedCell interface.
package csc143.sudoku;
public interface SelectedCell {
public void setSelected(int row, int col);
public int getSelectedRow();
public int getSelectedColumn();
}
Explanation / Answer
/** 02 * Support for the selected cell. Required part of 03 * the SudokuView class. 04 */ 05 public interface SelectedCell { 06 07 /** 08 * Selects the cell and places it in focus. 09 * @param row the row to the cell to select 10 * @param col the column to the cell to select 11 */ 12 public void setSelected(int row, int col); 13 14 /** 15 * Returns the row to the currently selected cell. 16 * @return the row to the currently selected cell 17 */ 18 public int getSelectedRow(); 19 20 /** 21 * Returns the column to the currently selected cell. 22 * @return the column to the currently selected cell 23 */ 24 public int getSelectedColumn(); 25 26 }
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.