Updated Translation Controller

Translation Controller now uses 3 space tabbing consistently
This commit is contained in:
law39 2020-04-30 19:09:42 +01:00
parent 6b5cf0e457
commit dbf5d74ee8

View file

@ -24,91 +24,91 @@ import uk.ac.aber.cs221.group20.selfassessment.Question;
*/
public class TranslationController extends SharedCodeController{
// //////////////// //
// Class variables. //
// //////////////// //
// //////////////// //
// Class variables. //
// //////////////// //
public static DictionaryEntry answer = new DictionaryEntry();
public static DictionaryEntry answer = new DictionaryEntry();
// /////////////////// //
// Instance variables. //
// /////////////////// //
// /////////////////// //
// Instance variables. //
// /////////////////// //
/**
* Represents the word that will be randomly chosen from the practiceList.
*/
int chosenWord = 0;
@FXML
private TextField translationBox;
/**
* Represents the word that will be randomly chosen from the practiceList.
*/
int chosenWord = 0;
@FXML
private TextField translationBox;
@FXML
private Text typeOfTest;
@FXML
private Text typeOfTest;
@FXML
private Text wordToTranslate;
@FXML
private Text wordToTranslate;
@FXML
private Text correctGuesses;
@FXML
private Text correctGuesses;
@FXML
private Text incorrectGuesses;
@FXML
private Text incorrectGuesses;
@FXML
private ImageView submitButton;
@FXML
private ImageView submitButton;
Random rand = new Random();
Random rand = new Random();
// //////// //
// Methods. //
// //////// //
// //////// //
// Methods. //
// //////// //
/**
* Loads the test for the first time, filling the practice list with words from the dictionary,
* deciding if this test will be from English to Welsh or Welsh to English, and generating
* which is the first word the user will have to translate.
*/
@FXML
private void initialize(){
setup();
currentPageIcon.setImage(new Image("file:src/main/resources/assets/icons/white_icons/50px/pass-fail-50.png"));
currentPageText.setText("Study");
/**
* Loads the test for the first time, filling the practice list with words from the dictionary,
* deciding if this test will be from English to Welsh or Welsh to English, and generating
* which is the first word the user will have to translate.
*/
@FXML
private void initialize(){
setup();
currentPageIcon.setImage(new Image("file:src/main/resources/assets/icons/white_icons/50px/pass-fail-50.png"));
currentPageText.setText("Study");
studyIcon.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/pass-fail-50.png"));
studyText.setFill(Color.BLACK);
studyIcon.setImage(new Image("file:src/main/resources/assets/icons/black_icons/50px/pass-fail-50.png"));
studyText.setFill(Color.BLACK);
submitButton.setImage(new Image ("file:src/main/resources/assets/icons/black_icons/50px/right-50.png"));
submitButton.setImage(new Image ("file:src/main/resources/assets/icons/black_icons/50px/right-50.png"));
correctGuesses.setText("Correct answers: " + AssessmentGenerator.getTotalCorrectAnswers());
incorrectGuesses.setText("Total answers: " + AssessmentGenerator.getTotalAnswers());
correctGuesses.setText("Correct answers: " + AssessmentGenerator.getTotalCorrectAnswers());
incorrectGuesses.setText("Total answers: " + AssessmentGenerator.getTotalAnswers());
if(AssessmentGenerator.isEnglish){
wordToTranslate.setText(answer.getEnglish());
}
else{
wordToTranslate.setText(answer.getWelsh());
}
}
if(AssessmentGenerator.isEnglish){
wordToTranslate.setText(answer.getEnglish());
}
else{
wordToTranslate.setText(answer.getWelsh());
}
}
/**
* Takes the word the user inputs and compares it to the correct answer using
* the checkAnswer function in the QuestionClass.
*/
@FXML
void translateWord() {
/**
* Takes the word the user inputs and compares it to the correct answer using
* the checkAnswer function in the QuestionClass.
*/
@FXML
void translateWord() {
ArrayList<String> usersInput = new ArrayList<>();
usersInput.add(translationBox.getText());
ArrayList<String> usersInput = new ArrayList<>();
usersInput.add(translationBox.getText());
ArrayList<DictionaryEntry> correctTranslation = new ArrayList<>();
correctTranslation.add(answer);
ArrayList<DictionaryEntry> correctTranslation = new ArrayList<>();
correctTranslation.add(answer);
Question.checkAnswer(correctTranslation, usersInput, AssessmentGenerator.isEnglish);
Question.checkAnswer(correctTranslation, usersInput, AssessmentGenerator.isEnglish);
AssessmentGenerator.goToNextQuestion();
AssessmentGenerator.goToNextQuestion();
}
}
}