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

Method Board3

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

Method to create third 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

313 * @param is_loaded True if the board is loaded from a file.
314 */
315 public void Board3(boolean is_loaded){
316 reset_screen();
317 grid = new GridLayout(11, 8, 2, 2);
318 setLayout(grid);
319 boardType=3;
320 score = -1;
321 moves.clear();
322
323 //Fill the board if it was not loaded from a file.
324 if (!is_loaded){
325 board = new JButton[8][8];
326 for (int i = 0; i < 8; ++i){
327 for (int j = 0; j < 8; ++j){
328 board[i][j] = new JButton();
329 if ( (i==0||i==1||i==2||i==6||i==7) &&
330 (j!=2&&j!=3&&j!=4) )
331 board[i][j].setBackground(Color.WHITE);
332 else board[i][j].setBackground(Color.BLACK);
333 }
334 }
335 board[4][3].setBackground(Color.GRAY);
336 }
337
338 //Adding cells to frame.
339 addBoard();
340
341 //Adding game buttons to frame.
342 add(reset);
343 add(load);
344 add(save);
345 add(undo);
346 add(pegNumber);
347 add(emptyCells);
348 add(pegsOut);
349 add (auto);
350 add(new JLabel());add(new JLabel());add(new JLabel());
351 add(autoAll);
352 add(new JLabel());add(new JLabel());add(new JLabel());add(new JLabel());
353
354 //Adding radio buttons to frame.
355 add(new JLabel()); add(type1);add(type2);add(type3);add(type4);add(type5);add(type6); add(new JLabel());
356 addingListenersType();
357 }
358
359 /**
360 * Method to create fourth 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