Added method to generate questions for match the meaning

This commit is contained in:
maj83 2020-04-28 11:21:43 +01:00
parent ab7f1bec7d
commit cf5e47b58c

View file

@ -1,8 +1,9 @@
package uk.ac.aber.cs22120.group20.selfassessment;
import uk.ac.aber.cs22120.group20.json.WelshDictionary;
import uk.ac.aber.cs22120.group20.javafx.Application;
import uk.ac.aber.cs22120.group20.json.DictionaryEntry;
import java.util.LinkedList;
import java.util.Random;
/**
* Class that contains methods to create a randomised list of questions that will
@ -19,8 +20,8 @@ public class AssessmentGenerator extends Question {
* @param wordList
* @return
*/
public LinkedList<Question> generateAssessment(LinkedList<WelshDictionary> wordList){
public LinkedList<Question> generateAssessment(LinkedList<DictionaryEntry> wordList){
return null;
}
/**
@ -29,7 +30,8 @@ public class AssessmentGenerator extends Question {
* practice words as the parameter.
* @return
*/
public LinkedList<Question> generateWordMatch(LinkedList<WelshDictionary>){
public LinkedList<Question> generateWordMatch(LinkedList<DictionaryEntry> a){
return null;
}
@ -39,8 +41,46 @@ public class AssessmentGenerator extends Question {
* words as the parameter.
* @return
*/
public LinkedList<Question> generateSixMeanings(LinkedList<WelshDictionar>){
public static void generateSixMeanings(LinkedList<DictionaryEntry> practiseList){
//CHANGE DICTIONARY TO PRACTISE LIST
Random rand = new Random();
boolean isDuplicate = false;
do{
int rand_q=rand.nextInt(Application.dictionary.size()-1);
DictionaryEntry pickedQuestion = Application.dictionary.get(rand_q);
//If size of list is greater than 1 check for duplicates...
if(MatchTheMeaningQuestion.setOfQuestions.size()>=1){
for (DictionaryEntry setOfQuestion : MatchTheMeaningQuestion.setOfQuestions) {
//If it is duplicate change isDuplicate to true and break
if (setOfQuestion.equals(pickedQuestion)) {
isDuplicate = true;
break;
}
}
//If duplicate wasn't found add entry to the list
if(!isDuplicate){
MatchTheMeaningQuestion.setOfQuestions.add(pickedQuestion);
}
//... otherwise, add entry to the
}else{
MatchTheMeaningQuestion.setOfQuestions.add(pickedQuestion);
}
isDuplicate =false;
}while(MatchTheMeaningQuestion.setOfQuestions.size()<5);
}
/**
@ -49,8 +89,8 @@ public class AssessmentGenerator extends Question {
* the parameter.
* @return
*/
public LinkedList<Question> generateWordEnter(LinkedList<WelshDictionary>){
public LinkedList<Question> generateWordEnter(LinkedList<DictionaryEntry> a){
return null;
}