- Updated the Node interface and its implementations to include a strength() function. This is a double value between 0 and 1 representing the percent activation.

- Updated the PlayerModel to fix a bug in the high score tracking.
- Created HighScoreDialog.java, which displays the high scores from a PlayerModel. In the future, it will have a "New Game" button so that it can be used to transition between games.
This commit is contained in:
Marshall
2012-04-26 13:04:41 -04:00
parent 0cfe26faf1
commit 24096b50a8
5 changed files with 104 additions and 14 deletions

View File

@@ -0,0 +1,69 @@
package view;
import javax.swing.BorderFactory;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import model.playerModel.PlayerModel;
public class HighScoreDialog extends JDialog {
/**
*
*/
private static final long serialVersionUID = 1L;
public static void main(String[] args) {
JFrame x = new JFrame();
x.setDefaultCloseOperation(EXIT_ON_CLOSE);
x.setVisible(true);
PlayerModel pm = new PlayerModel();
pm.logGame(100);
pm.logGame(90);
pm.logGame(80);
pm.logGame(70);
pm.logGame(60);
pm.logGame(50);
pm.logGame(40);
pm.logGame(30);
pm.logGame(20);
pm.logGame(10);
pm.logGame(98);
pm.logGame(105);
new HighScoreDialog(x, pm);
}
public HighScoreDialog(JFrame owner, PlayerModel pm) {
super(owner, "Game over!", true);
String text = "<html>";
text += "<b>Game Over!</b>";
text += "<br><br>";
text += "<em>High Scores:</em>";
text += "<br><ol>";
int[] highScores = pm.getHighScores();
loop: for (int i = 0; i < highScores.length; i++) {
if (highScores[i] == -1) {
break loop;
}
else {
text += "<li>" + highScores[i] + "</li>";
}
}
text += "</ol></html>";
JLabel label = new JLabel(text);
label.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
this.add(label);
this.pack();
this.setResizable(false);
this.setVisible(true);
}
}