From 71a40f542f1f3b21a5c99722cfb904d68a86fd3b Mon Sep 17 00:00:00 2001 From: bms <bradley_small@hotmail.com> Date: Mon, 16 Aug 2021 10:00:13 -0400 Subject: [PATCH] 24DiceGame-Comments --- pom.xml | 15 ++++++++++----- src/main/java/com/small/dicegame/App.java | 5 +++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 35e4f5b..6d79a35 100644 --- a/pom.xml +++ b/pom.xml @@ -12,6 +12,16 @@ <groupId>org.example</groupId> <artifactId>24DiceGame</artifactId> <version>1.0-SNAPSHOT</version> + <packaging>jar</packaging> + + <properties> + <java.version>14</java.version> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>${java.version}</maven.compiler.source> + <maven.compiler.target>${java.version}</maven.compiler.target> + <maven.compiler.release>${java.version}</maven.compiler.release> + </properties> + <dependencies> <dependency> <groupId>junit</groupId> @@ -21,9 +31,4 @@ </dependency> </dependencies> - <properties> - <maven.compiler.source>16</maven.compiler.source> - <maven.compiler.target>16</maven.compiler.target> - </properties> - </project> \ No newline at end of file diff --git a/src/main/java/com/small/dicegame/App.java b/src/main/java/com/small/dicegame/App.java index cb4dccb..c23e9b6 100644 --- a/src/main/java/com/small/dicegame/App.java +++ b/src/main/java/com/small/dicegame/App.java @@ -20,12 +20,14 @@ public class App extends JFrame { initGui(); } + //TODO Try to keep initialization methods reasonably short, could move construction parts to additional methods private void initGui() { setTitle("24 Dice Game"); setDefaultCloseOperation(EXIT_ON_CLOSE); setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS)); Box diceBox = Box.createHorizontalBox(); + //TODO Could move to separate method: buildBoxDiceGUI(diceBox) for (int index = 0; index < NUMBER_OF_DICE; index++) { dieBoxes[index] = new DieBox(index); dieBoxes[index].addActionListener(e -> { @@ -41,6 +43,7 @@ public class App extends JFrame { add(diceBox); JPanel buttonPanel = new JPanel(); + //TODO Could move to separate method: initRollButton() rollButton.setEnabled(false); rollButton.addActionListener(e -> { if (areAllHeld()) { @@ -52,6 +55,7 @@ public class App extends JFrame { buttonPanel.add(rollButton); buttonPanel.add(newGameButton); + //TODO Could move to separate method: initGameButton() newGameButton.addActionListener(e -> { newGameButton.setEnabled(false); rollButton.setEnabled(true); @@ -84,6 +88,7 @@ public class App extends JFrame { } } + //TODO Java naming style for methods that return Boolean to use prefix 'is' or 'has', example: hasHeldAllDice() private boolean areAllHeld() { return Arrays.stream(dieBoxes).noneMatch(DieBox::isButtonEnabled); -- GitLab