Loading src/edu/bu/ec504/spr19/samegame/sg.java +17 −26 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ class sg extends GUI implements ActionListener,ItemListener { private JMenuItem quitGame; private JRadioButtonMenuItem noPlayerMenuItem,simplePlayerMenuItem, lazyPlayerMenuItem, // various automatic player options smarterPlayerMenuItem; private static boolean IamApplet = true; // true iff the application is run as an applet, false otherwise // ... Brain elements Brain theBrain; // the Brain (automated player) for the game Loading Loading @@ -147,15 +146,19 @@ class sg extends GUI implements ActionListener,ItemListener { * @return the score achieved from clicking on a region of length <b>level</b> */ final public int score(int level, CircleColor theColor) { int tmp; if (level==1) return -10; else tmp = (int) (level * Math.log(level)); switch (theColor) { case Blue: return level+1; case Red: return 2*level*level; case Green: return level*level; return -tmp; case Green: case Blue: return tmp; default: return 0; // I don't know this color return 0; } } Loading Loading @@ -402,7 +405,6 @@ class sg extends GUI implements ActionListener,ItemListener { // if we've gotten here, it means that the game has ended int score = new Integer(totalPoints.getText()); if (!IamApplet) { highScore hs = new highScore(highScoreFile); hs.loadScores(); Loading @@ -427,16 +429,8 @@ class sg extends GUI implements ActionListener,ItemListener { JOptionPane.showMessageDialog(null, "Current high scores:\n"+hs.display()); } else { // I am in an applet, disable high scores (they won't work as currently implemented because of security reasons) JOptionPane.showMessageDialog(null, "Game Over (High Scores are disabled for Applets).\n You had "+score+" points.\n"+ "Your weighted score for this sized board was "+ highScore.hsComp.weightedScore( new highScore.HSdata("",width,height,score))+"."); } return false; /* // for debug - show states for (int ii=0; ii<width; ii++) for (int jj=0; jj<height; jj++) circles[ii][jj].debug=""+circles[ii][jj].getState();*/ } Loading Loading @@ -516,15 +510,12 @@ class sg extends GUI implements ActionListener,ItemListener { } /** * Designed to allow the applet to run as a standalone application * See <a href="http://www.informit.com/content/images/078970935X/sourcecode/ch13.zip">here</a>} * Runs the application */ public static void main(String args[]) { JFrame myApp = new sg(); //JFrame myAppFrame = new JFrame("Ari's samegame"); myApp.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); myApp.setSize(defaultWindowWidth, defaultWindowHeight); myApp.setVisible(true); } } No newline at end of file Loading
src/edu/bu/ec504/spr19/samegame/sg.java +17 −26 Original line number Diff line number Diff line Loading @@ -57,7 +57,6 @@ class sg extends GUI implements ActionListener,ItemListener { private JMenuItem quitGame; private JRadioButtonMenuItem noPlayerMenuItem,simplePlayerMenuItem, lazyPlayerMenuItem, // various automatic player options smarterPlayerMenuItem; private static boolean IamApplet = true; // true iff the application is run as an applet, false otherwise // ... Brain elements Brain theBrain; // the Brain (automated player) for the game Loading Loading @@ -147,15 +146,19 @@ class sg extends GUI implements ActionListener,ItemListener { * @return the score achieved from clicking on a region of length <b>level</b> */ final public int score(int level, CircleColor theColor) { int tmp; if (level==1) return -10; else tmp = (int) (level * Math.log(level)); switch (theColor) { case Blue: return level+1; case Red: return 2*level*level; case Green: return level*level; return -tmp; case Green: case Blue: return tmp; default: return 0; // I don't know this color return 0; } } Loading Loading @@ -402,7 +405,6 @@ class sg extends GUI implements ActionListener,ItemListener { // if we've gotten here, it means that the game has ended int score = new Integer(totalPoints.getText()); if (!IamApplet) { highScore hs = new highScore(highScoreFile); hs.loadScores(); Loading @@ -427,16 +429,8 @@ class sg extends GUI implements ActionListener,ItemListener { JOptionPane.showMessageDialog(null, "Current high scores:\n"+hs.display()); } else { // I am in an applet, disable high scores (they won't work as currently implemented because of security reasons) JOptionPane.showMessageDialog(null, "Game Over (High Scores are disabled for Applets).\n You had "+score+" points.\n"+ "Your weighted score for this sized board was "+ highScore.hsComp.weightedScore( new highScore.HSdata("",width,height,score))+"."); } return false; /* // for debug - show states for (int ii=0; ii<width; ii++) for (int jj=0; jj<height; jj++) circles[ii][jj].debug=""+circles[ii][jj].getState();*/ } Loading Loading @@ -516,15 +510,12 @@ class sg extends GUI implements ActionListener,ItemListener { } /** * Designed to allow the applet to run as a standalone application * See <a href="http://www.informit.com/content/images/078970935X/sourcecode/ch13.zip">here</a>} * Runs the application */ public static void main(String args[]) { JFrame myApp = new sg(); //JFrame myAppFrame = new JFrame("Ari's samegame"); myApp.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE); myApp.setSize(defaultWindowWidth, defaultWindowHeight); myApp.setVisible(true); } } No newline at end of file