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

Method Board4

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

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

361 * @param is_loaded True if the board is loaded from a file.
362 */
363 public void Board4(boolean is_loaded){
364 reset_screen();
365 grid = new GridLayout(10, 7, 2, 2);
366 setLayout(grid);
367 boardType = 4;
368 score = -1;
369 moves.clear();
370
371 //Fill the board if it was not loaded from a file.
372 if (!is_loaded){
373 board = new JButton[7][7];
374 for (int i = 0; i < 7; ++i){
375 for (int j = 0; j < 7; ++j){
376 board[i][j] = new JButton();
377 if ( (i==0||i==1||i==5||i==6) && (j!=2&&j!=3&&j!=4) )
378 board[i][j].setBackground(Color.WHITE);
379 else board[i][j].setBackground(Color.BLACK);
380 }
381 }
382 board[3][3].setBackground(Color.GRAY);
383 }
384
385 //Adding cells to frame.
386 addBoard();
387
388 //Adding game buttons to frame.
389 add(reset); add(load); add(save); add(undo); add(pegNumber); add(emptyCells); add(pegsOut);
390 add(new JLabel()); add(new JLabel());
391 add (auto);
392 add(new JLabel());
393 add(autoAll);
394 add(new JLabel()); add(new JLabel());
395
396 //Adding radio buttons to frame.
397 add(type1);add(type2);add(type3);add(type4);add(type5);add(type6);
398 addingListenersType();
399 }
400
401 /**
402 * Method to create fifth 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