From 3b6075adc068b24f7d23ac6e41f569e468aff6d8 Mon Sep 17 00:00:00 2001 From: voroscsoki Date: Wed, 22 May 2024 19:13:25 +0200 Subject: [PATCH 1/5] Bunch of refactoring --- src/main/java/Controll/Controller.java | 39 +++++++++---------- src/main/java/Controll/Menu.java | 20 ++++------ src/main/java/Drawing/MechanicDraw.java | 2 +- src/main/java/Drawing/SaboteurDraw.java | 2 +- .../java/Fields/ActiveFields/Cistern.java | 4 +- src/main/java/Fields/ActiveFields/Pump.java | 4 +- src/main/java/Fields/ActiveFields/Spring.java | 4 +- src/main/java/Fields/Pipe.java | 4 +- .../StringResourceController.java | 4 +- .../java/Fields/ActiveFields/CisternTest.java | 1 - test/main/java/StepDefs.java | 3 +- 11 files changed, 38 insertions(+), 49 deletions(-) diff --git a/src/main/java/Controll/Controller.java b/src/main/java/Controll/Controller.java index 801f977..3b86ab4 100644 --- a/src/main/java/Controll/Controller.java +++ b/src/main/java/Controll/Controller.java @@ -74,10 +74,6 @@ public static void setTest(boolean value) { * Name of the used file */ private static String fileName = ""; - /** - * Path of the used file - */ - private static String filePath = ""; /** * List of the test result @@ -97,7 +93,7 @@ public static void setTest(boolean value) { /** * List of the commands */ - public static final List commandList = new ArrayList<>(); + protected static final List commandList = new ArrayList<>(); /** * Number of new pumps with commands @@ -132,7 +128,7 @@ public static void setActivePlayer(Player p) { activePlayers.add(currentPlayer); } - public static Player GetActivePlayer() { + public static Player getActivePlayer() { return currentPlayer; } @@ -155,7 +151,7 @@ public static boolean changeActivePlayer() { * Function for controlling the game. * Reads a command than calls a function to execute it. */ - public static void Run() { + public static void run() { while (!commandList.isEmpty()) { String command = commandList.get(0); commandList.remove(0); @@ -283,6 +279,7 @@ public static void Game() { if (commandList.isEmpty()) { commandList.add(stdInScanner.nextLine()); } + stdInScanner.close(); String command = commandList.get(0); commandList.remove(0); String[] cmd = command.split(" "); @@ -375,22 +372,22 @@ public static void Game() { step(cmd); break; case ("endturn"): - endturn(cmd); + endturn(); break; case ("count"): - count(cmd); + count(); break; case ("test"): test(cmd); break; case ("setend"): - setend(cmd); + setend(); break; case ("setpump"): setpump(cmd); break; case ("restart"): - restart(cmd); + restart(); break; case ("exit"): return; @@ -399,10 +396,10 @@ public static void Game() { } if (moves == activePlayers.size()) { moves = 0; - endturn(cmd); + endturn(); } } - Run(); + run(); } /** @@ -413,7 +410,6 @@ public static void load(String cmd) { String modifiedPath = cmd.replace("/", File.separator).replace("\\", File.separator); try (Scanner scanner = new Scanner(new File(rootDirectory + File.separator + modifiedPath));) { outResults.clear(); - filePath = modifiedPath; String separator = "\\"; String[] tmp = cmd.replaceAll(Pattern.quote(separator), "\\\\").split("\\\\"); fileName = tmp[tmp.length - 1]; @@ -429,7 +425,8 @@ public static void load(String cmd) { public static void loadFileFromSrcToReader(String fileNameToOpen) { // a text file is located in src folder in the project Path rootDir = Paths.get(".").normalize().toAbsolutePath(); - File file = new File(rootDir.toString() + "/" + fileNameToOpen); + Path filePath = rootDir.resolve(fileNameToOpen); + File file = filePath.toFile(); try (Reader input = new FileReader(file)) { try (BufferedReader br = new BufferedReader(input)) { @@ -717,11 +714,11 @@ public static void show(String[] cmd) { switch (commands[1]) { case "player": if (test) outResults.add(p.toString()); - else logger.log(Level.INFO, p::toString); + else logger.log(Level.INFO, p::toString); // Fix: Wrap the method call in a lambda function break; case "field": if (test) outResults.add(objectReverseNames.get(p.getStandingField())); - else logger.log(Level.INFO, objectReverseNames.get(p.getStandingField())); + else logger.log(Level.INFO, () -> objectReverseNames.get(p.getStandingField())); // Fix: Wrap the method call in a lambda function break; default: break; @@ -1163,7 +1160,7 @@ public static void step(String[] cmd) { * Function for ending a turn. * Responsible for calling the step function for all steppable objects. */ - public static void endturn(String[] cmd) { + public static void endturn() { //elvégzi a kör végével járó lépéseket (vízszámolás, objektumok step függvényének hívása stb…) //vízszámlálás //water counter lehet hogy üres @@ -1181,7 +1178,7 @@ public static void endturn(String[] cmd) { /** * Function for countig the points for the two sides. */ - public static void count(String[] cmd) { + public static void count() { waterCounter.count(); if (test) outResults.add(StringResourceController.GOOD_ACTION); else logger.log(Level.INFO, StringResourceController.GOOD_ACTION); @@ -1190,7 +1187,7 @@ public static void count(String[] cmd) { /** * Function for restaring the game. */ - public static void restart(String[] cmd) { + public static void restart() { random = true; objectNames.clear(); objectReverseNames.clear(); @@ -1213,7 +1210,7 @@ public static void test(String[] cmd) { /** * Function for signaling to the watercounter that the game ended. */ - public static void setend(String[] cmd) { + public static void setend() { waterCounter.setEnd(); if (test) outResults.add(StringResourceController.GOOD_ACTION); else logger.log(Level.INFO, StringResourceController.GOOD_ACTION); diff --git a/src/main/java/Controll/Menu.java b/src/main/java/Controll/Menu.java index a85db6d..7f46b30 100644 --- a/src/main/java/Controll/Menu.java +++ b/src/main/java/Controll/Menu.java @@ -1,16 +1,12 @@ package main.java.Controll; -import javax.swing.*; -import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.Color; import javax.swing.WindowConstants; -import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.List; - import javax.swing.JFrame; import javax.swing.JTextField; import javax.swing.JButton; @@ -127,15 +123,15 @@ public JButton getPlayButton() { return newGame; } - public ArrayList getActionButtons() { - ArrayList actionButtons = new ArrayList(); + public List getActionButtons() { + ArrayList actionButtons = new ArrayList<>(); if (vg == null) return actionButtons; - actionButtons.add(vg.repairButton); - actionButtons.add(vg.breakButton); - actionButtons.add(vg.makeSlipperyButton); - actionButtons.add(vg.makeStickyButton); - actionButtons.add(vg.putDownButton); + actionButtons.add(ViewGame.repairButton); + actionButtons.add(ViewGame.breakButton); + actionButtons.add(ViewGame.makeSlipperyButton); + actionButtons.add(ViewGame.makeStickyButton); + actionButtons.add(ViewGame.putDownButton); return actionButtons; } @@ -161,7 +157,7 @@ public void actionPerformed(ActionEvent e) { Controller.commandList.add("addplayer D Sab" + i); } } - Controller.Run(); // egyszer fut le, felépíti a pályát, utána a függvényeit kell majd hívni + Controller.run(); // egyszer fut le, felépíti a pályát, utána a függvényeit kell majd hívni Controller.create(); Controller.setActivePlayer(Controller.getAllPlayers().get(0)); diff --git a/src/main/java/Drawing/MechanicDraw.java b/src/main/java/Drawing/MechanicDraw.java index 409e795..18771b4 100644 --- a/src/main/java/Drawing/MechanicDraw.java +++ b/src/main/java/Drawing/MechanicDraw.java @@ -40,7 +40,7 @@ public MechanicDraw(int tmpX, int tmpY) { @Override public void Draw(JPanel panel, Graphics2D g) { Mechanic m = (Mechanic)ViewGame.objectDrawNames.get(this); - Player current = Controller.GetActivePlayer(); + Player current = Controller.getActivePlayer(); mecName = Controller.objectReverseNames.get(m); mec.setText(mecName); Field f = m.getStandingField(); diff --git a/src/main/java/Drawing/SaboteurDraw.java b/src/main/java/Drawing/SaboteurDraw.java index d4655e1..3376a18 100644 --- a/src/main/java/Drawing/SaboteurDraw.java +++ b/src/main/java/Drawing/SaboteurDraw.java @@ -42,7 +42,7 @@ public SaboteurDraw(int tmpX, int tmpY) { @Override public void Draw(JPanel panel, Graphics2D g) { Saboteur s = (Saboteur)ViewGame.objectDrawNames.get(this); - Player current = Controller.GetActivePlayer(); + Player current = Controller.getActivePlayer(); sabName = Controller.objectReverseNames.get(s); sab.setText(sabName); Field f = s.getStandingField(); diff --git a/src/main/java/Fields/ActiveFields/Cistern.java b/src/main/java/Fields/ActiveFields/Cistern.java index 8122e12..afb7105 100644 --- a/src/main/java/Fields/ActiveFields/Cistern.java +++ b/src/main/java/Fields/ActiveFields/Cistern.java @@ -84,10 +84,10 @@ public Pipe pickUpPipe() { @Override public String toString() { ArrayList players = this.getPlayers(); - String playerBuilder = StringResourceController.stingBuilder(players); + String playerBuilder = StringResourceController.stringBuilder(players); ArrayList pipes = this.getPipes(); - String pipeBuilder = StringResourceController.stingBuilder(pipes); + String pipeBuilder = StringResourceController.stringBuilder(pipes); return "name: "+ Controller.objectReverseNames.get(this) + "\noccupied: " + this.isOccupied() diff --git a/src/main/java/Fields/ActiveFields/Pump.java b/src/main/java/Fields/ActiveFields/Pump.java index c97a27d..f99ec78 100644 --- a/src/main/java/Fields/ActiveFields/Pump.java +++ b/src/main/java/Fields/ActiveFields/Pump.java @@ -156,12 +156,12 @@ public String toString() { private String getPlayerNames() { ArrayList players = this.getPlayers(); - return StringResourceController.stingBuilder(players); + return StringResourceController.stringBuilder(players); } private String getPipeNames(){ ArrayList pipes = this.getPipes(); - return StringResourceController.stingBuilder(pipes); + return StringResourceController.stringBuilder(pipes); } } diff --git a/src/main/java/Fields/ActiveFields/Spring.java b/src/main/java/Fields/ActiveFields/Spring.java index 9334d0d..053a9bb 100644 --- a/src/main/java/Fields/ActiveFields/Spring.java +++ b/src/main/java/Fields/ActiveFields/Spring.java @@ -61,11 +61,11 @@ public void step() { @Override public String toString() { ArrayList players = this.getPlayers(); - String playerBuilder = StringResourceController.stingBuilder(players); + String playerBuilder = StringResourceController.stringBuilder(players); ArrayList pipes = this.getPipes(); - String pipeBuilder = StringResourceController.stingBuilder(pipes); + String pipeBuilder = StringResourceController.stringBuilder(pipes); return "name: "+ Controller.objectReverseNames.get(this) + "\noccupied: " + this.isOccupied() diff --git a/src/main/java/Fields/Pipe.java b/src/main/java/Fields/Pipe.java index 58c375c..b164842 100644 --- a/src/main/java/Fields/Pipe.java +++ b/src/main/java/Fields/Pipe.java @@ -342,10 +342,10 @@ public void step(){ @Override public String toString() { ArrayList players = this.getPlayers(); - String playerBuilder = StringResourceController.stingBuilder(players); + String playerBuilder = StringResourceController.stringBuilder(players); List localFields = this.getFields(); - String fieldBuilder = StringResourceController.stingBuilder(localFields); + String fieldBuilder = StringResourceController.stringBuilder(localFields); return "name: " + Controller.objectReverseNames.get(this) + "\noccupied: " + this.isOccupied() + "\nwater: " + getWaterNoChange() diff --git a/src/main/java/StringResource/StringResourceController.java b/src/main/java/StringResource/StringResourceController.java index 0ffc4ca..7895a6c 100644 --- a/src/main/java/StringResource/StringResourceController.java +++ b/src/main/java/StringResource/StringResourceController.java @@ -13,9 +13,7 @@ private StringResourceController(){} public static final String GOOD_ACTION = "Sikeres művelet"; public static final String WATER = "water"; public static final String RANDOM_ON = "A véletlen események be lettek kapcsolva."; - public static final String INVALID_ACTION = "A műveletet nem lehet végrehajtani"; - - public static String stingBuilder(List collection){ + public static String stringBuilder(List collection){ StringBuilder builder = new StringBuilder("null"); if(collection != null) { for (int i = 0; i < collection.size(); i++) { diff --git a/test/main/java/Fields/ActiveFields/CisternTest.java b/test/main/java/Fields/ActiveFields/CisternTest.java index 5e74474..eb86477 100644 --- a/test/main/java/Fields/ActiveFields/CisternTest.java +++ b/test/main/java/Fields/ActiveFields/CisternTest.java @@ -5,7 +5,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Controll.Controller; import main.java.Fields.Pipe; class CisternTest { diff --git a/test/main/java/StepDefs.java b/test/main/java/StepDefs.java index 0377d2b..ffb9214 100644 --- a/test/main/java/StepDefs.java +++ b/test/main/java/StepDefs.java @@ -9,7 +9,6 @@ import io.cucumber.java.en.Then; import io.cucumber.java.en.When; -import java.io.FileNotFoundException; import java.util.HashMap; import java.util.Map; @@ -23,7 +22,7 @@ public class StepDefs { public void gameInitialized() { Controller.load("test/resources/testpalya.txt"); - Controller.Run(); + Controller.run(); Controller.create(); Controller.setActivePlayer(Controller.getAllPlayers().get(0)); } From b3ea4e4f7a7515b90c0cfb8a63eb8b96a34ada50 Mon Sep 17 00:00:00 2001 From: voroscsoki Date: Wed, 22 May 2024 19:16:23 +0200 Subject: [PATCH 2/5] Fixed invalid signature --- src/main/java/Controll/Controller.java | 8 ++++---- src/main/java/Controll/ViewGame.java | 8 ++++---- .../java/StringResource/StringResourceController.java | 1 + 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main/java/Controll/Controller.java b/src/main/java/Controll/Controller.java index 3b86ab4..f7febc8 100644 --- a/src/main/java/Controll/Controller.java +++ b/src/main/java/Controll/Controller.java @@ -242,22 +242,22 @@ public static void run() { step(cmd); break; case ("endturn"): - endturn(cmd); + endturn(); break; case ("count"): - count(cmd); + count(); break; case ("test"): test(cmd); break; case ("setend"): - setend(cmd); + setend(); break; case ("setpump"): setpump(cmd); break; case ("restart"): - restart(cmd); + restart(); break; case ("exit"): return; diff --git a/src/main/java/Controll/ViewGame.java b/src/main/java/Controll/ViewGame.java index 9f7c831..ae9fb40 100644 --- a/src/main/java/Controll/ViewGame.java +++ b/src/main/java/Controll/ViewGame.java @@ -321,7 +321,7 @@ public void actionPerformed(ActionEvent e) { } if(e.getSource() == putDownButton){ cmd[1] = Controller.getActivePlayerName(); - if(Controller.GetActivePlayer().getStandingField() instanceof Pipe) Controller.placepump(cmd); + if(Controller.getActivePlayer().getStandingField() instanceof Pipe) Controller.placepump(cmd); else Controller.connect(cmd); successful = true; } @@ -339,13 +339,13 @@ public static void changeText(String[] cmd){ boolean b = Controller.changeActivePlayer(); activePlayer.setText("Active Player: " + Controller.getActivePlayerName()); if (b) { - Controller.endturn(cmd); + Controller.endturn(); mecPoints.setText("Mechanic: " + Controller.waterCounter.getMechanic()); sabPoints.setText("Saboteur: " + Controller.waterCounter.getSaboteur()); ++round; if(round == maxRounds){ - Controller.setend(cmd); - Controller.endturn(cmd); + Controller.setend(); + Controller.endturn(); mecPoints.setText("Mechanic: " + Controller.waterCounter.getMechanic()); sabPoints.setText("Saboteur: " + Controller.waterCounter.getSaboteur()); vg.THE_END(); diff --git a/src/main/java/StringResource/StringResourceController.java b/src/main/java/StringResource/StringResourceController.java index 7895a6c..b4c3a70 100644 --- a/src/main/java/StringResource/StringResourceController.java +++ b/src/main/java/StringResource/StringResourceController.java @@ -10,6 +10,7 @@ private StringResourceController(){} public static final String FILE_NOT_FOUND = "File not found"; public static final String WRONG_PLAYER = "Nem te vagy a soron következő játékos!"; public static final String WRONG_ACTION = "Sikertelen művelet"; + public static final String INVALID_ACTION = "A műveletet nem lehet végrehajtani"; public static final String GOOD_ACTION = "Sikeres művelet"; public static final String WATER = "water"; public static final String RANDOM_ON = "A véletlen események be lettek kapcsolva."; From 25e38bdc4ad874010ac2884cbe285e3233ac4332 Mon Sep 17 00:00:00 2001 From: voroscsoki Date: Wed, 22 May 2024 19:22:27 +0200 Subject: [PATCH 3/5] List type fix --- test/main/java/ResponseTimeSampler.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/main/java/ResponseTimeSampler.java b/test/main/java/ResponseTimeSampler.java index 3eb7d60..a825481 100644 --- a/test/main/java/ResponseTimeSampler.java +++ b/test/main/java/ResponseTimeSampler.java @@ -50,7 +50,7 @@ public SampleResult runTest(JavaSamplerContext context) { JButton playButton = menu.getPlayButton(); simulateButtonClick(playButton); result.sampleStart(); // start timing - ArrayList actionButtons = menu.getActionButtons(); + ArrayList actionButtons = (ArrayList) menu.getActionButtons(); for (JButton bt : actionButtons) { simulateButtonClick(bt); } @@ -59,7 +59,7 @@ public SampleResult runTest(JavaSamplerContext context) { JButton playButton = menu.getPlayButton(); simulateButtonClick(playButton); result.sampleStart(); // start timing - ArrayList actionButtons = menu.getActionButtons(); + ArrayList actionButtons = (ArrayList) menu.getActionButtons(); for (int i = 0; i < 1000000; i++){ if (i % 100 == 0) System.out.println(i); From e83917f114c43b89923656643e062b4cecea4cb1 Mon Sep 17 00:00:00 2001 From: voroscsoki Date: Wed, 22 May 2024 19:25:32 +0200 Subject: [PATCH 4/5] Sonar action updated to all branches --- .github/workflows/build.yml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2a68a6c..2a3e64f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,10 +2,7 @@ name: SonarCloud on: push: branches: - - main - - Manuális-és-statikus-ellenőrzés - - Sonar-Fixes - - maven + - '**' pull_request: types: [opened, synchronize, reopened] jobs: From 5824aa4bb46da64f140abf72e0c577ac01295fbe Mon Sep 17 00:00:00 2001 From: voroscsoki Date: Wed, 22 May 2024 19:33:53 +0200 Subject: [PATCH 5/5] Refactor according to package name rules --- src/main/java/Drawing/CisternDraw.java | 7 +++-- src/main/java/Drawing/Drawable.java | 2 +- src/main/java/Drawing/MechanicDraw.java | 20 ++++++------- src/main/java/Drawing/PipeDraw.java | 7 +++-- src/main/java/Drawing/PumpDraw.java | 6 ++-- src/main/java/Drawing/SaboteurDraw.java | 20 ++++++------- src/main/java/Drawing/SpringDraw.java | 7 +++-- src/main/java/Enums/Fluid.java | 2 +- .../Fields/ActiveFields/ActiveFields.java | 8 ++--- .../java/Fields/ActiveFields/Cistern.java | 10 +++---- src/main/java/Fields/ActiveFields/Pump.java | 10 +++---- src/main/java/Fields/ActiveFields/Spring.java | 10 +++---- src/main/java/Fields/Field.java | 10 +++---- src/main/java/Fields/Pipe.java | 14 ++++----- src/main/java/Interfaces/Steppable.java | 2 +- src/main/java/Players/Mechanic.java | 10 +++---- src/main/java/Players/Player.java | 8 ++--- src/main/java/Players/Saboteur.java | 4 +-- .../StringResourceController.java | 6 ++-- .../{Controll => control}/Controller.java | 30 +++++++++---------- src/main/java/{Controll => control}/Menu.java | 2 +- .../java/{Controll => control}/ViewGame.java | 10 +++---- .../{Controll => control}/WaterCounter.java | 8 ++--- test/main/java/Controll/WaterCounterTest.java | 5 ++-- .../java/Fields/ActiveFields/CisternTest.java | 4 ++- .../java/Fields/ActiveFields/PumpTest.java | 3 +- .../java/Fields/ActiveFields/SpringTest.java | 5 ++-- test/main/java/Fields/PipeTest.java | 14 +++++---- test/main/java/Players/MechanicTest.java | 7 +++-- test/main/java/Players/SaboteurTest.java | 7 +++-- test/main/java/ResponseTimeSampler.java | 5 ++-- test/main/java/StepDefs.java | 8 ++--- 32 files changed, 142 insertions(+), 129 deletions(-) rename src/main/java/{Controll => control}/Controller.java (98%) rename src/main/java/{Controll => control}/Menu.java (99%) rename src/main/java/{Controll => control}/ViewGame.java (98%) rename src/main/java/{Controll => control}/WaterCounter.java (96%) diff --git a/src/main/java/Drawing/CisternDraw.java b/src/main/java/Drawing/CisternDraw.java index d413b52..eb08615 100644 --- a/src/main/java/Drawing/CisternDraw.java +++ b/src/main/java/Drawing/CisternDraw.java @@ -1,8 +1,9 @@ -package main.java.Drawing; - -import main.java.Controll.ViewGame; +package main.java.drawing; import javax.swing.*; + +import main.java.control.ViewGame; + import java.awt.*; /** diff --git a/src/main/java/Drawing/Drawable.java b/src/main/java/Drawing/Drawable.java index 3e85acb..c4c5ce5 100644 --- a/src/main/java/Drawing/Drawable.java +++ b/src/main/java/Drawing/Drawable.java @@ -1,4 +1,4 @@ -package main.java.Drawing; +package main.java.drawing; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/Drawing/MechanicDraw.java b/src/main/java/Drawing/MechanicDraw.java index 18771b4..256b7fd 100644 --- a/src/main/java/Drawing/MechanicDraw.java +++ b/src/main/java/Drawing/MechanicDraw.java @@ -1,14 +1,14 @@ -package main.java.Drawing; +package main.java.drawing; -import main.java.Controll.Controller; -import main.java.Controll.ViewGame; -import main.java.Fields.ActiveFields.Cistern; -import main.java.Fields.ActiveFields.Pump; -import main.java.Fields.ActiveFields.Spring; -import main.java.Fields.Field; -import main.java.Fields.Pipe; -import main.java.Players.Mechanic; -import main.java.Players.Player; +import main.java.control.Controller; +import main.java.control.ViewGame; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; +import main.java.fields.activefields.Pump; +import main.java.fields.activefields.Spring; +import main.java.players.Mechanic; +import main.java.players.Player; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/Drawing/PipeDraw.java b/src/main/java/Drawing/PipeDraw.java index 5128688..7e366a9 100644 --- a/src/main/java/Drawing/PipeDraw.java +++ b/src/main/java/Drawing/PipeDraw.java @@ -1,8 +1,9 @@ -package main.java.Drawing; - -import main.java.Controll.ViewGame; +package main.java.drawing; import javax.swing.*; + +import main.java.control.ViewGame; + import java.awt.*; /** diff --git a/src/main/java/Drawing/PumpDraw.java b/src/main/java/Drawing/PumpDraw.java index 5095b44..6a1743f 100644 --- a/src/main/java/Drawing/PumpDraw.java +++ b/src/main/java/Drawing/PumpDraw.java @@ -1,7 +1,7 @@ -package main.java.Drawing; +package main.java.drawing; -import main.java.Controll.ViewGame; -import main.java.Fields.ActiveFields.Pump; +import main.java.control.ViewGame; +import main.java.fields.activefields.Pump; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/Drawing/SaboteurDraw.java b/src/main/java/Drawing/SaboteurDraw.java index 3376a18..0400953 100644 --- a/src/main/java/Drawing/SaboteurDraw.java +++ b/src/main/java/Drawing/SaboteurDraw.java @@ -1,14 +1,14 @@ -package main.java.Drawing; +package main.java.drawing; -import main.java.Controll.Controller; -import main.java.Controll.ViewGame; -import main.java.Fields.ActiveFields.Cistern; -import main.java.Fields.ActiveFields.Pump; -import main.java.Fields.ActiveFields.Spring; -import main.java.Fields.Field; -import main.java.Fields.Pipe; -import main.java.Players.Player; -import main.java.Players.Saboteur; +import main.java.control.Controller; +import main.java.control.ViewGame; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; +import main.java.fields.activefields.Pump; +import main.java.fields.activefields.Spring; +import main.java.players.Player; +import main.java.players.Saboteur; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/Drawing/SpringDraw.java b/src/main/java/Drawing/SpringDraw.java index 618f027..7a47545 100644 --- a/src/main/java/Drawing/SpringDraw.java +++ b/src/main/java/Drawing/SpringDraw.java @@ -1,8 +1,9 @@ -package main.java.Drawing; - -import main.java.Controll.ViewGame; +package main.java.drawing; import javax.swing.*; + +import main.java.control.ViewGame; + import java.awt.*; public class SpringDraw extends Drawable { diff --git a/src/main/java/Enums/Fluid.java b/src/main/java/Enums/Fluid.java index 491fc06..c046226 100644 --- a/src/main/java/Enums/Fluid.java +++ b/src/main/java/Enums/Fluid.java @@ -1,4 +1,4 @@ -package main.java.Enums; +package main.java.enums; public enum Fluid { DRY, STICKY, SLIPPERY diff --git a/src/main/java/Fields/ActiveFields/ActiveFields.java b/src/main/java/Fields/ActiveFields/ActiveFields.java index 2343fe9..a9bc09c 100644 --- a/src/main/java/Fields/ActiveFields/ActiveFields.java +++ b/src/main/java/Fields/ActiveFields/ActiveFields.java @@ -1,8 +1,8 @@ -package main.java.Fields.ActiveFields; +package main.java.fields.activefields; -import main.java.Fields.Field; -import main.java.Fields.Pipe; -import main.java.Players.Player; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.players.Player; import java.util.ArrayList; diff --git a/src/main/java/Fields/ActiveFields/Cistern.java b/src/main/java/Fields/ActiveFields/Cistern.java index afb7105..f6fedff 100644 --- a/src/main/java/Fields/ActiveFields/Cistern.java +++ b/src/main/java/Fields/ActiveFields/Cistern.java @@ -1,9 +1,9 @@ -package main.java.Fields.ActiveFields; +package main.java.fields.activefields; -import main.java.Controll.Controller; -import main.java.Fields.Pipe; -import main.java.Players.Player; -import main.java.StringResource.StringResourceController; +import main.java.control.Controller; +import main.java.fields.Pipe; +import main.java.players.Player; +import main.java.stringresource.StringResourceController; import java.util.ArrayList; import java.util.Random; diff --git a/src/main/java/Fields/ActiveFields/Pump.java b/src/main/java/Fields/ActiveFields/Pump.java index f99ec78..ca1fa5e 100644 --- a/src/main/java/Fields/ActiveFields/Pump.java +++ b/src/main/java/Fields/ActiveFields/Pump.java @@ -1,9 +1,9 @@ -package main.java.Fields.ActiveFields; +package main.java.fields.activefields; -import main.java.Controll.Controller; -import main.java.Fields.Pipe; -import main.java.Players.Player; -import main.java.StringResource.StringResourceController; +import main.java.control.Controller; +import main.java.fields.Pipe; +import main.java.players.Player; +import main.java.stringresource.StringResourceController; import java.util.ArrayList; import java.util.Random; diff --git a/src/main/java/Fields/ActiveFields/Spring.java b/src/main/java/Fields/ActiveFields/Spring.java index 053a9bb..822e46b 100644 --- a/src/main/java/Fields/ActiveFields/Spring.java +++ b/src/main/java/Fields/ActiveFields/Spring.java @@ -1,9 +1,9 @@ -package main.java.Fields.ActiveFields; +package main.java.fields.activefields; -import main.java.Controll.Controller; -import main.java.Fields.Pipe; -import main.java.Players.Player; -import main.java.StringResource.StringResourceController; +import main.java.control.Controller; +import main.java.fields.Pipe; +import main.java.players.Player; +import main.java.stringresource.StringResourceController; import java.util.ArrayList; diff --git a/src/main/java/Fields/Field.java b/src/main/java/Fields/Field.java index 2d6f83e..21830c1 100644 --- a/src/main/java/Fields/Field.java +++ b/src/main/java/Fields/Field.java @@ -1,9 +1,9 @@ -package main.java.Fields; +package main.java.fields; -import main.java.Fields.ActiveFields.ActiveFields; -import main.java.Fields.ActiveFields.Pump; -import main.java.Interfaces.Steppable; -import main.java.Players.Player; +import main.java.fields.activefields.ActiveFields; +import main.java.fields.activefields.Pump; +import main.java.interfaces.Steppable; +import main.java.players.Player; import java.util.ArrayList; diff --git a/src/main/java/Fields/Pipe.java b/src/main/java/Fields/Pipe.java index b164842..2f05131 100644 --- a/src/main/java/Fields/Pipe.java +++ b/src/main/java/Fields/Pipe.java @@ -1,11 +1,11 @@ -package main.java.Fields; +package main.java.fields; -import main.java.Controll.Controller; -import main.java.Enums.Fluid; -import main.java.Fields.ActiveFields.ActiveFields; -import main.java.Fields.ActiveFields.Pump; -import main.java.Players.Player; -import main.java.StringResource.StringResourceController; +import main.java.control.Controller; +import main.java.enums.Fluid; +import main.java.fields.activefields.ActiveFields; +import main.java.fields.activefields.Pump; +import main.java.players.Player; +import main.java.stringresource.StringResourceController; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/Interfaces/Steppable.java b/src/main/java/Interfaces/Steppable.java index 3442c81..d7b10b2 100644 --- a/src/main/java/Interfaces/Steppable.java +++ b/src/main/java/Interfaces/Steppable.java @@ -1,4 +1,4 @@ -package main.java.Interfaces; +package main.java.interfaces; /** * Steppable interface. diff --git a/src/main/java/Players/Mechanic.java b/src/main/java/Players/Mechanic.java index cce3b3c..394e192 100644 --- a/src/main/java/Players/Mechanic.java +++ b/src/main/java/Players/Mechanic.java @@ -1,9 +1,9 @@ -package main.java.Players; +package main.java.players; -import main.java.Controll.Controller; -import main.java.Fields.ActiveFields.ActiveFields; -import main.java.Fields.ActiveFields.Pump; -import main.java.Fields.Pipe; +import main.java.control.Controller; +import main.java.fields.Pipe; +import main.java.fields.activefields.ActiveFields; +import main.java.fields.activefields.Pump; /** diff --git a/src/main/java/Players/Player.java b/src/main/java/Players/Player.java index 346801a..d890501 100644 --- a/src/main/java/Players/Player.java +++ b/src/main/java/Players/Player.java @@ -1,8 +1,8 @@ -package main.java.Players; +package main.java.players; -import main.java.Fields.ActiveFields.Pump; -import main.java.Fields.Field; -import main.java.Fields.Pipe; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.fields.activefields.Pump; /** * Abstract class for the players. diff --git a/src/main/java/Players/Saboteur.java b/src/main/java/Players/Saboteur.java index 4a81e93..f91abd1 100644 --- a/src/main/java/Players/Saboteur.java +++ b/src/main/java/Players/Saboteur.java @@ -1,6 +1,6 @@ -package main.java.Players; +package main.java.players; -import main.java.Controll.Controller; +import main.java.control.Controller; /** diff --git a/src/main/java/StringResource/StringResourceController.java b/src/main/java/StringResource/StringResourceController.java index b4c3a70..a6608b5 100644 --- a/src/main/java/StringResource/StringResourceController.java +++ b/src/main/java/StringResource/StringResourceController.java @@ -1,9 +1,9 @@ -package main.java.StringResource; - -import main.java.Controll.Controller; +package main.java.stringresource; import java.util.List; +import main.java.control.Controller; + public final class StringResourceController { private StringResourceController(){} public static final String FALSE = "false"; diff --git a/src/main/java/Controll/Controller.java b/src/main/java/control/Controller.java similarity index 98% rename from src/main/java/Controll/Controller.java rename to src/main/java/control/Controller.java index f7febc8..a916460 100644 --- a/src/main/java/Controll/Controller.java +++ b/src/main/java/control/Controller.java @@ -1,18 +1,18 @@ -package main.java.Controll; - -import main.java.Drawing.*; -import main.java.Enums.Fluid; -import main.java.Fields.ActiveFields.ActiveFields; -import main.java.Fields.ActiveFields.Cistern; -import main.java.Fields.ActiveFields.Pump; -import main.java.Fields.ActiveFields.Spring; -import main.java.Fields.Field; -import main.java.Fields.Pipe; -import main.java.Interfaces.Steppable; -import main.java.Players.Mechanic; -import main.java.Players.Player; -import main.java.Players.Saboteur; -import main.java.StringResource.StringResourceController; +package main.java.control; + +import main.java.drawing.*; +import main.java.enums.Fluid; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.fields.activefields.ActiveFields; +import main.java.fields.activefields.Cistern; +import main.java.fields.activefields.Pump; +import main.java.fields.activefields.Spring; +import main.java.interfaces.Steppable; +import main.java.players.Mechanic; +import main.java.players.Player; +import main.java.players.Saboteur; +import main.java.stringresource.StringResourceController; import java.io.*; import java.nio.file.Path; diff --git a/src/main/java/Controll/Menu.java b/src/main/java/control/Menu.java similarity index 99% rename from src/main/java/Controll/Menu.java rename to src/main/java/control/Menu.java index 7f46b30..5bfa76b 100644 --- a/src/main/java/Controll/Menu.java +++ b/src/main/java/control/Menu.java @@ -1,4 +1,4 @@ -package main.java.Controll; +package main.java.control; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/src/main/java/Controll/ViewGame.java b/src/main/java/control/ViewGame.java similarity index 98% rename from src/main/java/Controll/ViewGame.java rename to src/main/java/control/ViewGame.java index ae9fb40..6bc3c7c 100644 --- a/src/main/java/Controll/ViewGame.java +++ b/src/main/java/control/ViewGame.java @@ -1,9 +1,9 @@ -package main.java.Controll; +package main.java.control; -import main.java.Drawing.Drawable; -import main.java.Drawing.PipeDraw; -import main.java.Enums.Fluid; -import main.java.Fields.Pipe; +import main.java.drawing.Drawable; +import main.java.drawing.PipeDraw; +import main.java.enums.Fluid; +import main.java.fields.Pipe; import javax.swing.*; import java.awt.*; diff --git a/src/main/java/Controll/WaterCounter.java b/src/main/java/control/WaterCounter.java similarity index 96% rename from src/main/java/Controll/WaterCounter.java rename to src/main/java/control/WaterCounter.java index 93bf0e1..97e7a25 100644 --- a/src/main/java/Controll/WaterCounter.java +++ b/src/main/java/control/WaterCounter.java @@ -1,10 +1,10 @@ -package main.java.Controll; - -import main.java.Fields.ActiveFields.Cistern; -import main.java.Fields.Pipe; +package main.java.control; import java.util.ArrayList; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; + import static java.lang.Math.abs; /** diff --git a/test/main/java/Controll/WaterCounterTest.java b/test/main/java/Controll/WaterCounterTest.java index 4131eeb..65ec957 100644 --- a/test/main/java/Controll/WaterCounterTest.java +++ b/test/main/java/Controll/WaterCounterTest.java @@ -5,8 +5,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Fields.Pipe; -import main.java.Fields.ActiveFields.Cistern; +import main.java.control.WaterCounter; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; class WaterCounterTest { private WaterCounter waterCounter; diff --git a/test/main/java/Fields/ActiveFields/CisternTest.java b/test/main/java/Fields/ActiveFields/CisternTest.java index eb86477..66a54b9 100644 --- a/test/main/java/Fields/ActiveFields/CisternTest.java +++ b/test/main/java/Fields/ActiveFields/CisternTest.java @@ -5,7 +5,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Fields.Pipe; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; +import main.java.fields.activefields.Pump; class CisternTest { private Cistern cistern; diff --git a/test/main/java/Fields/ActiveFields/PumpTest.java b/test/main/java/Fields/ActiveFields/PumpTest.java index ab8e4fa..f1746b4 100644 --- a/test/main/java/Fields/ActiveFields/PumpTest.java +++ b/test/main/java/Fields/ActiveFields/PumpTest.java @@ -7,7 +7,8 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Fields.Pipe; +import main.java.fields.Pipe; +import main.java.fields.activefields.Pump; class PumpTest { private Pump pump; diff --git a/test/main/java/Fields/ActiveFields/SpringTest.java b/test/main/java/Fields/ActiveFields/SpringTest.java index 7d57b0a..2bf4663 100644 --- a/test/main/java/Fields/ActiveFields/SpringTest.java +++ b/test/main/java/Fields/ActiveFields/SpringTest.java @@ -7,8 +7,9 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Fields.Pipe; -import main.java.Players.Mechanic; +import main.java.fields.Pipe; +import main.java.fields.activefields.Spring; +import main.java.players.Mechanic; class SpringTest { private Spring spring; diff --git a/test/main/java/Fields/PipeTest.java b/test/main/java/Fields/PipeTest.java index c53e1c7..e56aecc 100644 --- a/test/main/java/Fields/PipeTest.java +++ b/test/main/java/Fields/PipeTest.java @@ -7,12 +7,14 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Controll.Controller; -import main.java.Enums.Fluid; -import main.java.Fields.ActiveFields.ActiveFields; -import main.java.Fields.ActiveFields.Pump; -import main.java.Players.Mechanic; -import main.java.Players.Player; +import main.java.control.Controller; +import main.java.enums.Fluid; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.fields.activefields.ActiveFields; +import main.java.fields.activefields.Pump; +import main.java.players.Mechanic; +import main.java.players.Player; class PipeTest { private Pipe pipe; diff --git a/test/main/java/Players/MechanicTest.java b/test/main/java/Players/MechanicTest.java index eeef774..5eea536 100644 --- a/test/main/java/Players/MechanicTest.java +++ b/test/main/java/Players/MechanicTest.java @@ -5,9 +5,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Fields.Pipe; -import main.java.Fields.ActiveFields.Cistern; -import main.java.Fields.ActiveFields.Pump; +import main.java.fields.Pipe; +import main.java.fields.activefields.Cistern; +import main.java.fields.activefields.Pump; +import main.java.players.Mechanic; class MechanicTest { private Mechanic mechanic; diff --git a/test/main/java/Players/SaboteurTest.java b/test/main/java/Players/SaboteurTest.java index 7823155..0574875 100644 --- a/test/main/java/Players/SaboteurTest.java +++ b/test/main/java/Players/SaboteurTest.java @@ -5,9 +5,10 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; -import main.java.Enums.Fluid; -import main.java.Fields.Pipe; -import main.java.Fields.ActiveFields.Pump; +import main.java.enums.Fluid; +import main.java.fields.Pipe; +import main.java.fields.activefields.Pump; +import main.java.players.Saboteur; class SaboteurTest { private Saboteur saboteur; diff --git a/test/main/java/ResponseTimeSampler.java b/test/main/java/ResponseTimeSampler.java index a825481..c2d96c0 100644 --- a/test/main/java/ResponseTimeSampler.java +++ b/test/main/java/ResponseTimeSampler.java @@ -1,12 +1,13 @@ package main.java; -import main.java.Controll.Menu; -import main.java.Controll.ViewGame; import org.apache.jmeter.config.Arguments; import org.apache.jmeter.protocol.java.sampler.AbstractJavaSamplerClient; import org.apache.jmeter.protocol.java.sampler.JavaSamplerContext; import org.apache.jmeter.samplers.SampleResult; +import main.java.control.Menu; +import main.java.control.ViewGame; + import javax.swing.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; diff --git a/test/main/java/StepDefs.java b/test/main/java/StepDefs.java index ffb9214..7572fae 100644 --- a/test/main/java/StepDefs.java +++ b/test/main/java/StepDefs.java @@ -1,9 +1,9 @@ package main.java; -import main.java.Controll.Controller; -import main.java.Fields.Field; -import main.java.Fields.Pipe; -import main.java.Players.Player; +import main.java.control.Controller; +import main.java.fields.Field; +import main.java.fields.Pipe; +import main.java.players.Player; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then;