From 660a2bad48787a80a25d33655c6c938824334493 Mon Sep 17 00:00:00 2001 From: Ozan-Can Ekinci Date: Sun, 15 Jan 2023 21:12:22 +0100 Subject: [PATCH] refactoring: refactored variable names --- src/main/java/Gui/ActionHandler.java | 4 ++-- src/main/java/Gui/GameGui.java | 36 ++++++++++++++-------------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/main/java/Gui/ActionHandler.java b/src/main/java/Gui/ActionHandler.java index d8fd0e0..de84add 100644 --- a/src/main/java/Gui/ActionHandler.java +++ b/src/main/java/Gui/ActionHandler.java @@ -19,14 +19,14 @@ public class ActionHandler implements ActionListener { if (e.getSource() == GameGui.RestartBtn) { GameGui.questionNr = 0; GameGui.LosingPanel.setVisible(false); - GameGui.counter = 1; + GameGui.currentQuestion = 1; restartGame.startGame(); } if (e.getSource() == GameGui.RestartBtn1) { GameGui.questionNr = 0; GameGui.WinningPanel.setVisible(false); - GameGui.counter = 1; + GameGui.currentQuestion = 1; restartGame.startGame(); } diff --git a/src/main/java/Gui/GameGui.java b/src/main/java/Gui/GameGui.java index 4222ad7..89a3f1c 100644 --- a/src/main/java/Gui/GameGui.java +++ b/src/main/java/Gui/GameGui.java @@ -15,11 +15,11 @@ import game.runGame; public class GameGui implements GameGuiInterface { - public static JPanel MainPanel, ButtonPanel, headingPanel, WinningPanel, LosingPanel; - public static JLabel Headline, QuestionLabel, WinningLabel, LosingLabel, ShowQuestionNr, HighScoreLabel; + public static JPanel MainPanel, ButtonPanel, HeadingPanel, WinningPanel, LosingPanel; + public static JLabel HeadlineLabel, QuestionLabel, WinningLabel, LosingLabel, CurrentQuestionNrLabel, HighScoreLabel; public static JButton AnswersBtn1, AnswersBtn2, AnswersBtn3, AnswersBtn4, RestartBtn, RestartBtn1, ClosingBtn; public static int questionNr = 0; - public static int counter = 1; + public static int currentQuestion = 1; public static int highScore = 0; GridLayout grid; GridBagConstraints gbc; @@ -37,10 +37,10 @@ public class GameGui implements GameGuiInterface { public void CreatePanel() { MainPanel = new JPanel(); ButtonPanel = new JPanel(); - headingPanel = new JPanel(); + HeadingPanel = new JPanel(); grid = new GridLayout(2, 1); grid.setVgap(150); - headingPanel.setLayout(grid); + HeadingPanel.setLayout(grid); gui.Frame.add(MainPanel); } @@ -62,7 +62,7 @@ public class GameGui implements GameGuiInterface { LosingPanel = new JPanel(); LosingPanel.setLayout(new GridBagLayout()); LosingLabel = new JLabel(); - LosingLabel.setText("Du hast Frage " + (counter - 1) + " falsch beantwortet"); + LosingLabel.setText("Du hast Frage " + (currentQuestion - 1) + " falsch beantwortet"); LosingLabel.setVerticalAlignment(JLabel.CENTER); LosingLabel.setHorizontalAlignment(JLabel.CENTER); LosingLabel.setFont(new Font("Serif", Font.BOLD, 28)); @@ -92,7 +92,7 @@ public class GameGui implements GameGuiInterface { WinningPanel = new JPanel(); WinningPanel.setLayout(new GridBagLayout()); - WinningLabel = new JLabel("Du hast Gewonnen!"); + WinningLabel = new JLabel("Du hast Gewonnen"); WinningLabel.setVerticalAlignment(JLabel.CENTER); WinningLabel.setHorizontalAlignment(JLabel.CENTER); WinningLabel.setFont(new Font("Serif", Font.BOLD, 28)); @@ -109,21 +109,21 @@ public class GameGui implements GameGuiInterface { public void createShowQuestion(int i) { int numLines = runGame.CountFileLines("QandA/Money.txt"); String[] arrMoney = runGame.readFile("QandA/Money.txt", numLines); - String questionText = "Frage " + counter + ": " + arrMoney[i - 1] + " Euro"; - counter++; + String questionText = "Frage " + currentQuestion + ": " + arrMoney[i - 1] + " Euro"; + currentQuestion++; - ShowQuestionNr.setText(questionText); - MainPanel.add(ShowQuestionNr); + CurrentQuestionNrLabel.setText(questionText); + MainPanel.add(CurrentQuestionNrLabel); } @Override public void createHeadline() { - Headline = new JLabel("Wer wird Millionaer?"); - headingPanel.add(Headline); - ShowQuestionNr = new JLabel(); - MainPanel.add(headingPanel); - Headline.setHorizontalAlignment(JLabel.CENTER); - Headline.setFont(new Font("Serif", Font.BOLD, 28)); + HeadlineLabel = new JLabel("Wer wird Millionaer"); + HeadingPanel.add(HeadlineLabel); + CurrentQuestionNrLabel = new JLabel(); + MainPanel.add(HeadingPanel); + HeadlineLabel.setHorizontalAlignment(JLabel.CENTER); + HeadlineLabel.setFont(new Font("Serif", Font.BOLD, 28)); } @Override @@ -133,7 +133,7 @@ public class GameGui implements GameGuiInterface { QuestionLabel.setHorizontalAlignment(JLabel.CENTER); QuestionLabel.setVerticalAlignment(JLabel.NORTH); QuestionLabel.setFont(new Font("Serif", Font.BOLD, 20)); - headingPanel.add(QuestionLabel); + HeadingPanel.add(QuestionLabel); } @Override