Merge branch 'master' of https://gitlab.dcs.aber.ac.uk/ncw/gp20
This commit is contained in:
commit
4e1bb05b79
4 changed files with 70 additions and 22 deletions
0
dev/20200427/maj83/.gitkeep
Normal file
0
dev/20200427/maj83/.gitkeep
Normal file
48
dev/20200427/maj83/Question.java
Normal file
48
dev/20200427/maj83/Question.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
package uk.ac.aber.cs22120.group20.selfassessment;
|
||||
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
/**
|
||||
* Abstract class contains the basic information that all the shared information between the
|
||||
* types of test questions including the questions’ correct answers and possible answers. All question
|
||||
* classes will extend this class.
|
||||
* @Author
|
||||
* @Version
|
||||
* @See
|
||||
*/
|
||||
public class Question {
|
||||
|
||||
public int correctAnswer = 0;
|
||||
public int wrongAnswer =0;
|
||||
|
||||
/**
|
||||
* Constructor for
|
||||
* WordEnterQuestion that takes a WelshDictionary object that is being tested on as the parameter.
|
||||
* @param correctAnswer
|
||||
*/
|
||||
public void wordEnterQuestion(DictionaryEntry correctAnswer){
|
||||
|
||||
}
|
||||
|
||||
public void checkAnswer(ArrayList<DictionaryEntry> listOfCorrectQuestions, ArrayList<String>listOfAnswers, boolean isEnglish){
|
||||
if(isEnglish){
|
||||
for(int i=0; i<listOfCorrectQuestions.size();i++){
|
||||
if(listOfCorrectQuestions.get(i).getEnglish().equals(listOfAnswers.get(i))){
|
||||
correctAnswer++;
|
||||
}else wrongAnswer++;
|
||||
}
|
||||
}else{
|
||||
for(int i=0; i<listOfCorrectQuestions.size();i++){
|
||||
if(listOfCorrectQuestions.get(i).getWelsh().equals(listOfAnswers.get(i))){
|
||||
correctAnswer++;
|
||||
}else wrongAnswer++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
1
dev/20200427/top19/flashcardfx/hellofx
Submodule
1
dev/20200427/top19/flashcardfx/hellofx
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit c46b21b0a548aeac2d83e1dee0bd662d93f07dfb
|
|
@ -9,6 +9,10 @@ import javafx.scene.text.Text;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Random;
|
||||
|
||||
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
|
||||
import uk.ac.aber.cs22120.group20.javafx.Application;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Controller for the translationTest fxml file.
|
||||
|
@ -17,7 +21,7 @@ import java.util.Random;
|
|||
* @version 0.9
|
||||
*
|
||||
*/
|
||||
public class TranslationController {
|
||||
public class TranslationController extends Question {
|
||||
ArrayList<DictionaryEntry> practiceList = new ArrayList<>();
|
||||
|
||||
|
||||
|
@ -66,7 +70,7 @@ public class TranslationController {
|
|||
|
||||
submitButton.setImage(new Image ("file:src/main/resources/assets/right-icon.png"));
|
||||
|
||||
for(DictionaryEntry entry : App.dictionary){
|
||||
for(DictionaryEntry entry : Application.dictionary){
|
||||
if(entry.isPracticeWord()){
|
||||
practiceList.add(entry);
|
||||
}
|
||||
|
@ -82,10 +86,10 @@ public class TranslationController {
|
|||
incorrectGuesses.setText("Incorrect Guesses: 0");
|
||||
|
||||
if(englishOrWelsh){
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
}
|
||||
else{
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,25 +103,20 @@ public class TranslationController {
|
|||
@FXML
|
||||
void translateWord() {
|
||||
|
||||
ArrayList<String> usersInput = new ArrayList<>();
|
||||
usersInput.add(translationBox.getText());
|
||||
|
||||
if(englishOrWelsh) {
|
||||
if (translationBox.getText().equals(practiceList.get(chosenWord).getWelsh())) {
|
||||
correctGuessesInt++;
|
||||
} else {
|
||||
incorrectGuessesInt++;
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (translationBox.getText().equals(practiceList.get(chosenWord).getEnglish())) {
|
||||
correctGuessesInt++;
|
||||
} else {
|
||||
incorrectGuessesInt++;
|
||||
}
|
||||
}
|
||||
ArrayList<DictionaryEntry> correctTranslation = new ArrayList<>();
|
||||
correctTranslation.add(practiceList.get(chosenWord));
|
||||
|
||||
checkAnswer(correctTranslation, usersInput, englishOrWelsh);
|
||||
|
||||
|
||||
correctGuesses.setText("Correct Guesses: " + correctGuessesInt);
|
||||
incorrectGuesses.setText("Incorrect Guesses: " + incorrectGuessesInt);
|
||||
|
||||
|
||||
|
||||
correctGuesses.setText("Correct Guesses: " + correctAnswer);
|
||||
incorrectGuesses.setText("Incorrect Guesses: " + wrongAnswer);
|
||||
|
||||
|
||||
|
||||
|
@ -135,10 +134,10 @@ public class TranslationController {
|
|||
}
|
||||
|
||||
if(englishOrWelsh){
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
}
|
||||
else{
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getWelsh());
|
||||
wordToTranslate.setText(practiceList.get(chosenWord).getEnglish());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue