MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / Board2

Method Board2

Programs/Games/peg-solitaire/PegSolitaire.java:265–309  ·  view source on GitHub ↗

Method to create second board from scratch. @param is_loaded True if the board is loaded from a file.

(boolean is_loaded)

Source from the content-addressed store, hash-verified

263 * @param is_loaded True if the board is loaded from a file.
264 */
265 public void Board2(boolean is_loaded){
266 reset_screen();
267 grid = new GridLayout(11, 9, 2, 2);
268 setLayout(grid);
269 boardType = 2;
270 score = -1;
271 moves.clear();
272
273 //Fill the board if it was not loaded from a file.
274 if (!is_loaded){
275 board = new JButton[9][9];
276 for (int i = 0; i < 9; ++i){
277 if (i==0 || i==1 || i==2 || i==6 || i==7 || i==8){
278 for (int j = 0; j < 9; ++j){
279 board[i][j] = new JButton();
280 if (j==0 || j==1 || j==2 || j==6 || j==7 || j==8)
281 board[i][j].setBackground(Color.WHITE);
282 else
283 board[i][j].setBackground(Color.BLACK);
284 }
285 }
286 else{
287 for(int j = 0; j < 9; ++j){
288 board[i][j] = new JButton();
289 board[i][j].setBackground(Color.BLACK);
290 }
291 }
292 }
293 board[4][4].setBackground(Color.GRAY);
294 }
295
296 //Adding cells to frame.
297 addBoard();
298
299 //Adding game buttons to frame.
300 add(reset);
301 add(load); add(save);
302 add(undo);
303 add(pegNumber); add(emptyCells); add(pegsOut);
304 add (auto); add(autoAll);
305
306 //Adding radio buttons to frame.
307 add(type1);add(type2);add(type3);add(type4);add(type5);add(type6);
308 addingListenersType();
309 }
310
311 /**
312 * Method to create third board from scratch.

Callers

nothing calls this directly

Calls 4

reset_screenMethod · 0.95
addBoardMethod · 0.95
addingListenersTypeMethod · 0.95
addMethod · 0.65

Tested by

no test coverage detected