sceneEnum has been refactored to sceneType. Issue #15

This commit is contained in:
law39 2020-05-01 12:28:59 +01:00
parent 4f33ec150e
commit 76fce85de7
3 changed files with 15 additions and 16 deletions

View file

@ -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 scenes 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;
}
/**

View file

@ -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);
}
}

View file

@ -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);
}