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

Class PegSolitaire

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

PEG SOLITAIRE! Peg Solitaire class extended from JFrame and implements PegSolitaireGame interface. There are 3 inner classes - ButtonHandler (implements ActionListener interface) - CellHandler (implements ActionListener interface) - RadioButtonHandler (implements ItemListener) @author Mert

Source from the content-addressed store, hash-verified

20 */
21
22public class PegSolitaire extends JFrame implements PegSolitaireGame{
23 private GridLayout grid;
24 private JButton[][] board;
25 private JButton reset;
26 private JButton load;
27 private JButton save;
28 private JButton undo;
29 private JButton auto;
30 private JButton autoAll;
31 private JButton pegNumber;
32 private JButton emptyCells;
33 private JButton pegsOut;
34 private JRadioButton type1;
35 private JRadioButton type2;
36 private JRadioButton type3;
37 private JRadioButton type4;
38 private JRadioButton type5;
39 private JRadioButton type6;
40 private ButtonGroup radios;
41 private int size;
42 private int boardType;
43 private int score;
44 private boolean toggle;
45 private ArrayList<Integer> moves;
46
47 /** No parameter constructor.
48 * Creates buttons and constitute beginning frame.
49 */
50 public PegSolitaire(){
51 super("Peg Solitaire");
52 size = 859;
53 toggle = false;
54 moves = new ArrayList<Integer>();
55 boardType = 0;
56 score = -1;
57
58 //RADIO BUTTONS
59 type1 = new JRadioButton( "European Style", false );
60 type2 = new JRadioButton( "J.C. Wiegleb", false );
61 type3 = new JRadioButton( "Asymmetrical", false );
62 type4 = new JRadioButton( "English Style", false );
63 type5 = new JRadioButton( "Diamond", false );
64 type6 = new JRadioButton( "Triangular", false );
65
66 //GAME BUTTONS
67 reset = new JButton("RESET");
68 reset.setToolTipText("Reset the current game.");
69 load = new JButton("LOAD");
70 load.setToolTipText("Load game to a file.");
71 save = new JButton("SAVE");
72 save.setToolTipText("Save game to a file.");
73 undo = new JButton("UNDO");
74 undo.setToolTipText("Undo last move.");
75 auto = new JButton("AUTO");
76 auto.setToolTipText("Computer plays 1 move.");
77 autoAll = new JButton("AUTO ALL");
78 autoAll.setToolTipText("Computer plays until game ends.");
79 pegNumber = new JButton("PEG NUMBER");

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected