Changed AddWordController to start words as practice words

Changed false to true so words added to the dictionary will be added as practice words by default
This commit is contained in:
Henry Dugmore 2020-04-29 15:37:21 +01:00
parent 2bc2c415af
commit cd083bcd1b

View file

@ -43,6 +43,16 @@ public class AddWordController {
@FXML @FXML
protected void addButtonClick(ActionEvent actionEvent) { protected void addButtonClick(ActionEvent actionEvent) {
String trueWordType;
if (wordType.getValue() == "Masculine noun") {
trueWordType = "nm";
} else if (wordType.getValue() == "Feminine noun") {
trueWordType = "nf";
} else if (wordType.getValue() == "Verb") {
trueWordType = "verb";
} else {
trueWordType = "other";
}
boolean entryFound = false; boolean entryFound = false;
// one or more blank fields // one or more blank fields
if (english.getText() == null || welsh.getText() == null || wordType.getValue().equals("Type")) { if (english.getText() == null || welsh.getText() == null || wordType.getValue().equals("Type")) {
@ -55,7 +65,7 @@ public class AddWordController {
} else { } else {
for (DictionaryEntry entry : Application.dictionary) { for (DictionaryEntry entry : Application.dictionary) {
entryFound = false; entryFound = false;
DictionaryEntry newEntry = new DictionaryEntry(english.getText(), welsh.getText(), wordType.getValue()); DictionaryEntry newEntry = new DictionaryEntry(english.getText(), welsh.getText(), trueWordType);
if (entry.equals(newEntry)) { if (entry.equals(newEntry)) {
Alert alert = new Alert(Alert.AlertType.ERROR); Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Error"); alert.setTitle("Error");
@ -76,7 +86,10 @@ public class AddWordController {
alert.setContentText("Entry Added - English: " + english.getText() + " Welsh: " + welsh.getText() + " Type: " + wordType.getValue()); alert.setContentText("Entry Added - English: " + english.getText() + " Welsh: " + welsh.getText() + " Type: " + wordType.getValue());
alert.showAndWait(); alert.showAndWait();
DictionaryEntry dictionaryEntry = new DictionaryEntry(english.getText(), welsh.getText(), wordType.getValue());
DictionaryEntry dictionaryEntry = new DictionaryEntry(english.getText(), welsh.getText(), trueWordType);
dictionaryEntry.setPracticeWord(true);
Application.dictionary.contains(dictionaryEntry); Application.dictionary.contains(dictionaryEntry);
Application.dictionary.add(dictionaryEntry); Application.dictionary.add(dictionaryEntry);
@ -89,6 +102,7 @@ public class AddWordController {
english.clear(); english.clear();
welsh.clear(); welsh.clear();
wordType.setValue("Type"); wordType.setValue("Type");
trueWordType = null;
} }