Made wordType enum and added words are now in PL
This commit is contained in:
parent
c19822023a
commit
937b6beee8
4 changed files with 36 additions and 20 deletions
|
@ -51,15 +51,15 @@ public class AddWordController extends SharedCodeController {
|
|||
|
||||
@FXML
|
||||
protected void addButtonClick(ActionEvent actionEvent) {
|
||||
String trueWordType;
|
||||
DictionaryEntry.wordTypeEnum trueWordType;
|
||||
if (wordType.getValue() == "Masculine noun") {
|
||||
trueWordType = "nm";
|
||||
trueWordType = DictionaryEntry.wordTypeEnum.nm;
|
||||
} else if (wordType.getValue() == "Feminine noun") {
|
||||
trueWordType = "nf";
|
||||
trueWordType = DictionaryEntry.wordTypeEnum.nf;
|
||||
} else if (wordType.getValue() == "Verb") {
|
||||
trueWordType = "verb";
|
||||
trueWordType = DictionaryEntry.wordTypeEnum.verb;
|
||||
} else {
|
||||
trueWordType = "other";
|
||||
trueWordType = DictionaryEntry.wordTypeEnum.other;
|
||||
}
|
||||
boolean entryFound = false;
|
||||
// one or more blank fields
|
||||
|
@ -100,6 +100,7 @@ public class AddWordController extends SharedCodeController {
|
|||
dictionaryEntry.setPracticeWord(true);
|
||||
Application.dictionary.contains(dictionaryEntry);
|
||||
Application.dictionary.add(dictionaryEntry);
|
||||
Application.practiceList.add(dictionaryEntry);
|
||||
|
||||
// output of what was saved for testing
|
||||
// System.out.print(english.getText());
|
||||
|
|
|
@ -174,9 +174,9 @@ public class DictionaryController extends SharedCodeController {
|
|||
}
|
||||
);
|
||||
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nm")) {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}");
|
||||
} else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nf")) {
|
||||
} else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nf)) {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nf}");
|
||||
} else {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh());
|
||||
|
@ -184,7 +184,7 @@ public class DictionaryController extends SharedCodeController {
|
|||
});
|
||||
|
||||
english.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("verb")) {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.verb)) {
|
||||
return new SimpleStringProperty("to " + dictionaryEntryStringCellDataFeatures.getValue().getEnglish());
|
||||
} else {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getEnglish());
|
||||
|
@ -210,7 +210,7 @@ public class DictionaryController extends SharedCodeController {
|
|||
result = true; // Filter matches English
|
||||
// } else if (dictionaryEntry.getWordType().toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
// result = true; // Filter matches Word Type
|
||||
} else if (dictionaryEntry.getWordType().equals("verb") && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
} else if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
result = true; // Filter matches ['to' + a word] or [a word] if word is a verb
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import javafx.collections.FXCollections;
|
|||
import javafx.collections.ObservableList;
|
||||
import javafx.collections.transformation.FilteredList;
|
||||
import javafx.collections.transformation.SortedList;
|
||||
import javafx.css.converter.DurationConverter;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.image.Image;
|
||||
|
@ -104,7 +105,7 @@ public class PracticeListController extends SharedCodeController{
|
|||
result = true; // Filter matches English
|
||||
// } else if (dictionaryEntry.getWordType().toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
// result = true; // Filter matches Word Type
|
||||
} else if (dictionaryEntry.getWordType().equals("verb") && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
} else if (dictionaryEntry.getWordType().equals(DictionaryEntry.wordTypeEnum.verb) && ("to " + dictionaryEntry.getEnglish()).toLowerCase().contains(lowerCaseSearchFilter)) {
|
||||
result = true; // Filter matches ['to' + a word] or [a word] if word is a verb
|
||||
}
|
||||
}
|
||||
|
@ -161,9 +162,9 @@ public class PracticeListController extends SharedCodeController{
|
|||
|
||||
welsh.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nm")) {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nm)) {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nm}");
|
||||
} else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("nf")) {
|
||||
} else if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.nf)) {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh() + " {nf}");
|
||||
} else {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getWelsh());
|
||||
|
@ -171,7 +172,7 @@ public class PracticeListController extends SharedCodeController{
|
|||
});
|
||||
|
||||
english.setCellValueFactory(dictionaryEntryStringCellDataFeatures -> {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals("verb")) {
|
||||
if (dictionaryEntryStringCellDataFeatures.getValue().getWordType().equals(DictionaryEntry.wordTypeEnum.verb)) {
|
||||
return new SimpleStringProperty("to " + dictionaryEntryStringCellDataFeatures.getValue().getEnglish());
|
||||
} else {
|
||||
return new SimpleStringProperty(dictionaryEntryStringCellDataFeatures.getValue().getEnglish());
|
||||
|
|
|
@ -26,7 +26,11 @@ import uk.ac.aber.cs22120.group20.javafx.DictionaryController;
|
|||
public class DictionaryEntry {
|
||||
private String english;
|
||||
private String welsh;
|
||||
private String wordType;
|
||||
public enum wordTypeEnum {
|
||||
nm, nf, verb, other
|
||||
}
|
||||
private wordTypeEnum wordType;
|
||||
// private String wordType;
|
||||
private Boolean practiceWord;
|
||||
|
||||
|
||||
|
@ -46,9 +50,10 @@ public class DictionaryEntry {
|
|||
* @see Application
|
||||
* @see DictionaryController
|
||||
*/
|
||||
public DictionaryEntry(String english, String welsh, String wordType) {
|
||||
public DictionaryEntry(String english, String welsh, wordTypeEnum wordType) {
|
||||
this.english = english;
|
||||
this.welsh = welsh;
|
||||
// this.wordType = wordType;
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
|
@ -68,15 +73,22 @@ public class DictionaryEntry {
|
|||
this.welsh = welsh.trim();
|
||||
}
|
||||
|
||||
public String getWordType() {
|
||||
public wordTypeEnum getWordType() {
|
||||
return wordType;
|
||||
}
|
||||
// public word getWordType() {
|
||||
// return wordType;
|
||||
// }
|
||||
|
||||
public void setWordType(String wordType) {
|
||||
this.wordType = wordType.trim();
|
||||
public void setWordType(wordTypeEnum wordType) {
|
||||
this.wordType = wordType;
|
||||
}
|
||||
|
||||
public Boolean isPracticeWord() {
|
||||
// public void setWordType(String wordType) {
|
||||
// this.wordType = wordType;
|
||||
// }
|
||||
|
||||
public Boolean isPracticeWord() {
|
||||
return practiceWord;
|
||||
}
|
||||
|
||||
|
@ -87,6 +99,8 @@ public class DictionaryEntry {
|
|||
@Override
|
||||
public boolean equals(Object entry) {
|
||||
DictionaryEntry otherEntry = (DictionaryEntry) entry;
|
||||
return otherEntry.getEnglish().equals(this.getEnglish()) && otherEntry.getWelsh().equals(this.getWelsh()) && otherEntry.getWordType().equals(this.getWordType());
|
||||
return otherEntry.getEnglish().equals(this.getEnglish()) &&
|
||||
otherEntry.getWelsh().equals(this.getWelsh()) &&
|
||||
otherEntry.getWordType().equals(this.getWordType());
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue