From 76fce85de782d838ee7e3f198b5a390e005e759d Mon Sep 17 00:00:00 2001 From: law39 Date: Fri, 1 May 2020 12:28:59 +0100 Subject: [PATCH] sceneEnum has been refactored to sceneType. Issue #15 --- .../ac/aber/cs221/group20/javafx/ScreenSwitch.java | 14 +++++++------- .../cs221/group20/javafx/SharedCodeController.java | 8 ++++---- .../selfassessment/AssessmentGenerator.java | 9 ++++----- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/ScreenSwitch.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/ScreenSwitch.java index 24c27d2..2ef37b1 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/ScreenSwitch.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/ScreenSwitch.java @@ -14,7 +14,7 @@ import java.net.URL; * * @author Luke Wybar (LAW39) * @version 0.1 - * @see SceneEnum + * @see SceneType */ public class ScreenSwitch extends SharedCodeController { private static Scene scene; @@ -28,7 +28,7 @@ public class ScreenSwitch extends SharedCodeController { * @param stage This a JavaFX stage setup by application, this will be ready to have a scene assigned. */ public ScreenSwitch(Stage stage){ - scene = new Scene(fxmlLoader(SceneEnum.dictionaryScene)); + scene = new Scene(fxmlLoader(SceneType.dictionaryScene)); stage.setMinHeight(680); stage.setHeight(680); stage.setMinWidth(1100); @@ -70,10 +70,10 @@ public class ScreenSwitch extends SharedCodeController { /** * Method that is responsible for the switching between * JavaFX, with it taking the new scene’s name as an enum as a parameter. - * @see SceneEnum + * @see SceneType * @param newScene This is a SceneEnum of the scene which is requested to switch to */ - public static void swap(SceneEnum newScene){ + public static void swap(SceneType newScene){ Parent root = fxmlLoader(newScene); scene.setRoot(root); } @@ -85,7 +85,7 @@ public class ScreenSwitch extends SharedCodeController { * @param newScene This is a SceneEnum of the scene which is to be loaded in. * @return Parent containing the interpreted FXML. */ - private static Parent fxmlLoader(SceneEnum newScene){ + private static Parent fxmlLoader(SceneType newScene){ Parent root = null; try{ String fxmlName = newScene.getFXML(); @@ -102,7 +102,7 @@ public class ScreenSwitch extends SharedCodeController { return root; } - public enum SceneEnum{ + public enum SceneType { /** * Enum containing each of the scenes required for use in the program along with the FXML file names. * This is a sub-enum of ScreenSwitch @@ -132,7 +132,7 @@ public class ScreenSwitch extends SharedCodeController { * * @param fxmlName This is the FXML file name including extension. */ - SceneEnum(String fxmlName) { + SceneType(String fxmlName) { this.fxmlName = fxmlName; } /** diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/SharedCodeController.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/SharedCodeController.java index bb9b496..1d0c6fd 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/SharedCodeController.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/javafx/SharedCodeController.java @@ -133,7 +133,7 @@ abstract public class SharedCodeController { */ @FXML private void dictionaryIconClick() { - ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.dictionaryScene); } /** @@ -142,7 +142,7 @@ abstract public class SharedCodeController { */ @FXML private void practiceListIconClick() { - ScreenSwitch.swap(ScreenSwitch.SceneEnum.practiceListScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.practiceListScene); } /** @@ -163,7 +163,7 @@ abstract public class SharedCodeController { alert.setContentText("The practice list is currently empty, please add some practice words to use the Flashcard feature."); alert.showAndWait(); } else{ - ScreenSwitch.swap(ScreenSwitch.SceneEnum.flashcardScene); // Switch to flashcard scene if the program has practice words. + ScreenSwitch.swap(ScreenSwitch.SceneType.flashcardScene); // Switch to flashcard scene if the program has practice words. } } @@ -185,7 +185,7 @@ abstract public class SharedCodeController { @FXML private void addWordIconClick(){ - ScreenSwitch.swap(ScreenSwitch.SceneEnum.addWordScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.addWordScene); } } diff --git a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/selfassessment/AssessmentGenerator.java b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/selfassessment/AssessmentGenerator.java index 7389b64..373a44d 100644 --- a/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/selfassessment/AssessmentGenerator.java +++ b/src/Welsh Vocabulary Tutor/src/main/java/uk/ac/aber/cs221/group20/selfassessment/AssessmentGenerator.java @@ -3,7 +3,6 @@ package uk.ac.aber.cs221.group20.selfassessment; import javafx.scene.control.Alert; import javafx.scene.control.ButtonType; import uk.ac.aber.cs221.group20.javafx.*; -import uk.ac.aber.cs221.group20.javafx.*; import uk.ac.aber.cs221.group20.json.DictionaryEntry; import java.text.DecimalFormat; @@ -175,13 +174,13 @@ public class AssessmentGenerator { if (currentQuestion instanceof MatchTheMeaningQuestion) { MatchTheMeaningController.answer = ((MatchTheMeaningQuestion) currentQuestion).getCorrectAnswer(); - ScreenSwitch.swap(ScreenSwitch.SceneEnum.matchMeaningScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.matchMeaningScene); } else if (currentQuestion instanceof SixMeaningsQuestion) { SixMeaningsController.allQuestions = ((SixMeaningsQuestion) currentQuestion).getCorrectAnswer(); - ScreenSwitch.swap(ScreenSwitch.SceneEnum.sixMeaningScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.sixMeaningScene); } else if (currentQuestion instanceof TranslationQuestion) { TranslationController.answer = ((TranslationQuestion) currentQuestion).getCorrectAnswer(); - ScreenSwitch.swap(ScreenSwitch.SceneEnum.translationScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.translationScene); } else { System.err.print("The question has not been recognised"); System.err.println(currentQuestion); @@ -213,7 +212,7 @@ public class AssessmentGenerator { reset(); if (result.isEmpty() || result.get() == noBtn) { - ScreenSwitch.swap(ScreenSwitch.SceneEnum.dictionaryScene); + ScreenSwitch.swap(ScreenSwitch.SceneType.dictionaryScene); } else { generateAssessment(Application.practiceList); }