From 0745a04b8e154369e6f409899c4cf75d0cad14ab Mon Sep 17 00:00:00 2001 From: Minecon724 Date: Fri, 4 Oct 2024 18:40:01 +0200 Subject: [PATCH] Fix warnings --- src/main/java/eu/m724/CrosswordBuilder.java | 11 ++++++----- src/main/java/eu/m724/Generator.java | 14 ++++++-------- src/main/java/eu/m724/Renderer.java | 3 --- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/main/java/eu/m724/CrosswordBuilder.java b/src/main/java/eu/m724/CrosswordBuilder.java index 4a20007..9f2d95d 100644 --- a/src/main/java/eu/m724/CrosswordBuilder.java +++ b/src/main/java/eu/m724/CrosswordBuilder.java @@ -9,10 +9,10 @@ import java.util.Set; * TODO bad javadoc */ public class CrosswordBuilder { - private int width, height; - private String solution; - private Set words = new HashSet<>(); - private Set placedWords = new HashSet<>(); + private final int width, height; + private final String solution; + private final Set words = new HashSet<>(); + private final Set placedWords = new HashSet<>(); /** * Creates a new {@link CrosswordBuilder} @@ -65,7 +65,8 @@ public class CrosswordBuilder { public CrosswordBuilder generate() { System.out.println("Generator invoked"); - placedWords = Generator.generate(width, height, solution, words.toArray(Word[]::new)); + // TODO perhaps making this an assignment and making placedWords not final is better + placedWords.addAll(Generator.generate(width, height, solution, words.toArray(Word[]::new))); System.out.println("Generator done"); return this; } diff --git a/src/main/java/eu/m724/Generator.java b/src/main/java/eu/m724/Generator.java index bd6209a..6164d9d 100644 --- a/src/main/java/eu/m724/Generator.java +++ b/src/main/java/eu/m724/Generator.java @@ -1,20 +1,18 @@ package eu.m724; -import java.time.Duration; -import java.time.LocalTime; import java.util.HashSet; import java.util.Set; import java.util.concurrent.ThreadLocalRandom; public class Generator { - private int width, height; - private String solution; - private Word[] words; + private final int width, height; + private final String solution; + private final Word[] words; - private char[][] charArray; - private Set placedWords; + private final char[][] charArray; + private final Set placedWords; - private ThreadLocalRandom random = ThreadLocalRandom.current(); + private final ThreadLocalRandom random = ThreadLocalRandom.current(); private Generator(int width, int height, String solution, Word[] words) { this.width = width; diff --git a/src/main/java/eu/m724/Renderer.java b/src/main/java/eu/m724/Renderer.java index 7f98961..9f9f15b 100644 --- a/src/main/java/eu/m724/Renderer.java +++ b/src/main/java/eu/m724/Renderer.java @@ -13,9 +13,6 @@ public class Renderer { SVGGraphics2D g2 = new SVGGraphics2D(crossword.width() * TILE_SIZE, crossword.height() * TILE_SIZE); g2.setPaint(Color.BLACK); - FontRenderContext frc = g2.getFontRenderContext(); - Font font = g2.getFont(); - for (PlacedWord word : crossword.words()) { int x = word.x(); int y = word.y();