diff --git a/README.md b/README.md index bcf55f3..a2bde01 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,13 @@ Beispiel: mysql -u username -p database_name < file.sql ``` +## Hilfsprogramme + +Unter `src/tools` befinden sich zwei Hilfsprogramme. + +1. `migration` dieses Tool kann verwendet werden um Fragen aus einer `json` Datei in eine Datenbank zu uebertragen. +2. `uml_draw` wird verwendet um das unten gezeigte UML Diagramm zu generieren + ## UML Uebersicht: diff --git a/doc/assets/project_uml_diagram.png b/doc/assets/project_uml_diagram.png index 266df88..fb2979e 100644 Binary files a/doc/assets/project_uml_diagram.png and b/doc/assets/project_uml_diagram.png differ diff --git a/src/Main.java b/src/Main.java index d709def..f5bf22e 100644 --- a/src/Main.java +++ b/src/Main.java @@ -82,13 +82,9 @@ public void run() { f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setSize(1280, 720); f.setResizable(false); - // Entfernt Fensterrahmen, erst nachdem alle Exit-Buttons implementiert sind - // aktivieren - // f.setUndecorated(true); + f.setUndecorated(true); f.setLocationRelativeTo(null); f.setVisible(true); - // NOTE: vielleicht muessen wir das laden vom screen mit dem starten - // des routers synchronisieren. } }; diff --git a/src/controller/Game.java b/src/controller/Game.java index d622e6e..e0036cf 100644 --- a/src/controller/Game.java +++ b/src/controller/Game.java @@ -29,6 +29,11 @@ public class Game implements Controller { private Share share; private int iter; private int levelOffset; + + private ActionListener al1; + private ActionListener al2; + private ActionListener al3; + private ActionListener al4; public Game(Switcher s, QuestionStore store) { this.switcher = s; @@ -55,7 +60,7 @@ public void init(Share share) { System.exit(1); } this.state = (State) share.get(key); - + this.next(); if (this.question == null) { // TODO: maybe we should allow a screen switch from @@ -76,6 +81,7 @@ public void init(Share share) { private void next() { this.question = this.state.next(); + this.initLevelLabel(); this.initQuestion(this.share); } @@ -87,6 +93,7 @@ public void actionPerformed(ActionEvent e) { share.put("KEY_GAME_ITERATION", iter); share.put("KEY_GAME_ITERATION_MAX", 50); share.put("KEY_GAME_LEVEL_FK", state.getLevelfk()); + share.put("KEY_GAME_WIN", null); switcher.next(Screen.SCREEN_RESULT); } }; @@ -97,6 +104,7 @@ private void initQuestion(Share share) { ActionListener right = new ActionListener() { public void actionPerformed(ActionEvent e) { share.put("KEY_GAME_WIN", new Object()); + iter++; next(); if (question == null) { switcher.next(Screen.SCREEN_RESULT); @@ -182,7 +190,11 @@ public void initQuestionLabel(String q) { public void initAnswerNo1Button(String a, ActionListener al) { this.view.getAnswerNo1Button().setText("
"+a+"
"); this.view.getAnswerNo1Button().setVisible(true); + if (this.al1 != null) { + this.view.getAnswerNo1Button().removeActionListener(this.al1); + } this.view.getAnswerNo1Button().addActionListener(al); + this.al1 = al; } /** @@ -191,7 +203,11 @@ public void initAnswerNo1Button(String a, ActionListener al) { public void initAnswerNo2Button(String a, ActionListener al) { this.view.getAnswerNo2Button().setText(""+a+"
"); this.view.getAnswerNo2Button().setVisible(true); + if (this.al2 != null) { + this.view.getAnswerNo2Button().removeActionListener(this.al2); + } this.view.getAnswerNo2Button().addActionListener(al); + this.al2 = al; } /** @@ -200,7 +216,11 @@ public void initAnswerNo2Button(String a, ActionListener al) { public void initAnswerNo3Button(String a, ActionListener al) { this.view.getAnswerNo3Button().setText(""+a+"
"); this.view.getAnswerNo3Button().setVisible(true); + if (this.al3 != null) { + this.view.getAnswerNo3Button().removeActionListener(this.al3); + } this.view.getAnswerNo3Button().addActionListener(al); + this.al3 = al; } /** @@ -209,7 +229,12 @@ public void initAnswerNo3Button(String a, ActionListener al) { public void initAnswerNo4Button(String a, ActionListener al) { this.view.getAnswerNo4Button().setText(""+a+"
"); this.view.getAnswerNo4Button().setVisible(true); + if (this.al4 != null) { + this.view.getAnswerNo4Button().removeActionListener(this.al4); + } this.view.getAnswerNo4Button().addActionListener(al); + this.al4 = al; + } /** @@ -233,38 +258,38 @@ public void initLevelLabel() { this.view.getLevelLabel().setText(" Level:"); int levelfk = this.state.getLevelfk(); int iter = this.state.getIter()+this.levelOffset+this.state.getLevelfk(); - System.out.println(iter); + int level5 = 0; int level4 = 0; int level3 = 0; int level2 = 0; int level1 = 0; - if (iter > 5*levelfk && iter <= 6*levelfk) { + if (iter > 5*levelfk && iter < 6*levelfk) { level5 = iter%levelfk; } else if (iter > 5*levelfk) { level5 = levelfk; } - if (iter > 4*levelfk && iter <= 5*levelfk) { + if (iter > 4*levelfk && iter < 5*levelfk) { level4 = iter%levelfk; } else if (iter > 4*levelfk) { level4 = levelfk; } - if (iter > 3*levelfk && iter <= 4*levelfk) { + if (iter > 3*levelfk && iter < 4*levelfk) { level3 = iter%levelfk; } else if (iter > 3*levelfk) { level3 = levelfk; } - if (iter > 2*levelfk && iter <= 3*levelfk) { + if (iter > 2*levelfk && iter < 3*levelfk) { level2 = iter%levelfk; } else if (iter > 2*levelfk) { level2 = levelfk; } - if (iter > 1*levelfk && iter <= 2*levelfk) { + if (iter > 1*levelfk && iter < 2*levelfk) { level1 = iter%levelfk; } else if (iter > 1*levelfk) { level1 = levelfk; diff --git a/src/controller/Result.java b/src/controller/Result.java index 2691bee..5f90c9d 100644 --- a/src/controller/Result.java +++ b/src/controller/Result.java @@ -7,7 +7,6 @@ import javax.swing.JPanel; import model.Question; -import questions.QuestionStore; /** * @@ -17,12 +16,10 @@ public class Result implements Controller { private Switcher switcher; - // private QuestionStore store; private view.Result view; - public Result(Switcher s, QuestionStore store) { + public Result(Switcher s) { this.switcher = s; - // this.store = store; } /** @@ -38,16 +35,13 @@ public void init(Share share) { if (!win) { int iter = (int) share.get("KEY_GAME_ITERATION"); int iterMax = (int) share.get("KEY_GAME_ITERATION_MAX"); - int level = 0; - if (iter > 0) { - level = iterMax / iter * levelFK; - } else { - level++; - } + int offset = (int) share.get("KEY_GAME_START_ITER"); + + int level = (iter / levelFK) + 1 + (offset/levelFK); this.initLevelLeftLabel(); this.initLevelRightLabel(level, iterMax/levelFK); this.initScoreLeftLabel(); - this.initScoreRightLabel(iter, iterMax); + this.initScoreRightLabel(iter+offset, iterMax); this.initQuestionLeftLabel(iter + 1); this.initQuestionRightLabel(q.getQuestion()); this.initPlayerAnswerLeftLabel(); diff --git a/src/ui/Registry.java b/src/ui/Registry.java index 9780e1f..ca9b49f 100644 --- a/src/ui/Registry.java +++ b/src/ui/Registry.java @@ -37,7 +37,7 @@ public void init(Switcher s, QuestionStore store) { this.intern.put(Screen.SCREEN_START, (Controller) new Start(s)); this.intern.put(Screen.SCREEN_CATEGORY, (Controller) new Category(s, store)); this.intern.put(Screen.SCREEN_GAME, (Controller) new Game(s, store)); - this.intern.put(Screen.SCREEN_RESULT, (Controller) new Result(s, store)); + this.intern.put(Screen.SCREEN_RESULT, (Controller) new Result(s)); this.intern.put(Screen.SCREEN_OPTIONS, (Controller) new Options(s, store)); this.intern.put(Screen.SCREEN_EDIT, (Controller) new Edit(s, store)); this.intern.put(Screen.SCREEN_CREATE, (Controller) new Create(s, store));