Permalink
Browse files

Small fixes

  • Loading branch information...
1 parent 0dcb136 commit 1e413ee239bdb5d4a4571ca7355d0a86e949e532 @schauder committed Feb 11, 2014
@@ -2,24 +2,24 @@
import javax.swing.JFrame;
-public class CrossWordController {
+public class CrosswordController {
- private InputView view;
- private CrosswordGame crosswordGame;
+ private final InputView view;
+ private final CrosswordGame crosswordGame;
- public CrossWordController(InputView view, CrosswordGame crosswordGame) {
- super();
- this.view = view;
- this.crosswordGame = crosswordGame;
- }
+ public CrosswordController(InputView view, CrosswordGame crosswordGame) {
+ super();
+ this.view = view;
+ this.crosswordGame = crosswordGame;
+ }
- public void start() {
+ public void start() {
- view.addActionForSubmit(new WordInputActionListener(view, crosswordGame));
+ view.addActionForSubmit(new WordInputActionListener(view, crosswordGame));
- view.getInputView().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- view.getInputView().setVisible(true);
+ view.getInputView().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
+ view.getInputView().setVisible(true);
- }
+ }
}
@@ -5,16 +5,16 @@
public class GuiStarter {
- public static void main(String[] args) {
+ public static void main(String[] args) {
- InputView view = new InputView();
+ InputView view = new InputView();
- CrosswordGame crosswordGame = new CrosswordGame(new HashSet<String>(
- Arrays.asList("Haus", "Maus", "Auto")));
+ CrosswordGame crosswordGame = new CrosswordGame(new HashSet<String>(
+ Arrays.asList("Haus", "Maus", "Auto")));
- CrossWordController controller = new CrossWordController(view,
- crosswordGame);
- controller.start();
+ CrosswordController controller = new CrosswordController(view,
+ crosswordGame);
+ controller.start();
- }
+ }
}
@@ -10,42 +10,43 @@
public class InputView {
- JFrame frame = new JFrame("CrossWord");
-
- JTextField inputfield = new JTextField();
- JButton submit = new JButton("submit");
- ScoreBoard score = new ScoreBoard();
-
- public InputView() {
- inputfield.setPreferredSize(new Dimension(80, 20));
- frame.getContentPane().setLayout(new FlowLayout());
- frame.getContentPane().add(inputfield);
- frame.getContentPane().add(submit);
- frame.getContentPane().add(score.getScorePanel());
- frame.pack();
- }
-
- public JFrame getInputView() {
- return frame;
- }
-
- public void addActionForSubmit(ActionListener action) {
- submit.addActionListener(action);
- }
-
- /**
- * Access to inputfield
- *
- * @return
- */
- public String getInput() {
- return inputfield.getText();
-
- }
-
- public void newScore(int points) {
- score.newScore(points);
-
- }
+ JFrame frame = new JFrame("CrossWord");
+
+ JTextField inputfield = new JTextField();
+ JButton submit = new JButton("submit");
+ ScoreBoard score = new ScoreBoard();
+
+ public InputView() {
+ inputfield.setPreferredSize(new Dimension(80, 20));
+ frame.getContentPane().setLayout(new FlowLayout());
+ frame.getContentPane().add(inputfield);
+ frame.getContentPane().add(submit);
+
+ frame.getContentPane().add(score.getScorePanel());
+ frame.pack();
+ }
+
+ public JFrame getInputView() {
+ return frame;
+ }
+
+ public void addActionForSubmit(ActionListener action) {
+ submit.addActionListener(action);
+ }
+
+ /**
+ * Access to inputfield
+ *
+ * @return
+ */
+ public String getInput() {
+ return inputfield.getText();
+
+ }
+
+ public void newScore(int points) {
+ score.newScore(points);
+
+ }
}
@@ -5,27 +5,27 @@
public class ScoreBoard {
- JPanel container = new JPanel();
- JLabel text = new JLabel("Points:");
- JLabel points = new JLabel("0");
-
- public ScoreBoard() {
- container.add(text);
- container.add(points);
-
- }
-
- public JPanel getScorePanel() {
- return container;
- }
-
- /**
- * Add new value to label.
- *
- * @param newScore
- */
- public void newScore(int newScore) {
- points.setText(Integer.valueOf(newScore).toString());
- }
+ private final JPanel container = new JPanel();
+ private final JLabel text = new JLabel("Points:");
+ private final JLabel points = new JLabel("0");
+
+ public ScoreBoard() {
+ container.add(text);
+ container.add(points);
+
+ }
+
+ public JPanel getScorePanel() {
+ return container;
+ }
+
+ /**
+ * Add new value to label.
+ *
+ * @param newScore
+ */
+ public void newScore(int newScore) {
+ points.setText(Integer.valueOf(newScore).toString());
+ }
}

0 comments on commit 1e413ee

Please sign in to comment.