use of eu.tn.model.Sentences in project TNCY-English-Project by mrngg.
the class AnswerSheetController method updateSheet.
public void updateSheet() throws IOException {
if (actualTest.successRules() != 0) {
actualRules = actualTest.randomRules().getName();
for (Rules r : actualTest.getRules()) {
if (r.getName().equals(actualRules)) {
r.setVisited(true);
actualSentences = r.randomSentences().getName();
for (Sentences s : r.getSentences()) {
if (s.getName().equals(actualSentences)) {
s.setVisited(true);
}
}
if (r.getError() >= 3) {
hint.setText(r.getHint());
}
}
}
sentences.setText(actualSentences);
answer.setText("");
} else {
for (Rules r : actualTest.getRules()) {
r.setSuccess(0);
r.setVisited(false);
r.setError(0);
for (Sentences s : r.getSentences()) {
s.setVisited(false);
}
}
Stage primaryStage = new Stage();
primaryStage.setTitle("Shakespeare");
BorderPane root = new BorderPane();
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("../view/EndScreen.fxml"));
loader.setControllerFactory((iC -> new EndScreenController(actualTest)));
root.setCenter(loader.load());
primaryStage.setOnCloseRequest(event -> {
Platform.exit();
});
primaryStage.setTitle("Shakespeare");
primaryStage.setScene(new Scene(root, 710, 532));
primaryStage.show();
Stage stage = (Stage) validateB.getScene().getWindow();
stage.close();
}
}
use of eu.tn.model.Sentences in project TNCY-English-Project by mrngg.
the class AnswerSheetController method validate.
public void validate() throws IOException {
if (answer.getText() != null) {
for (Rules r : actualTest.getRules()) {
if (r.getName().equals(actualRules)) {
for (Sentences s : r.getSentences()) {
if (s.getName().equals(actualSentences)) {
if (answer.getText().equals(s.getAnswer())) {
r.setSuccess(r.getSuccess() + 1);
r.setError(0);
} else {
r.setSuccess(0);
r.setError(r.getError() + 1);
}
}
}
}
}
updateSheet();
}
}
use of eu.tn.model.Sentences in project TNCY-English-Project by mrngg.
the class AnswerSheetController method correctSentence.
public void correctSentence() throws IOException {
for (Rules r : actualTest.getRules()) {
if (r.getName().equals(actualRules)) {
for (Sentences s : r.getSentences()) {
if (s.getName().equals(actualSentences)) {
if (s.getAnswer().equals("")) {
r.setSuccess(r.getSuccess() + 1);
r.setError(0);
} else {
r.setSuccess(0);
r.setError(r.getError() + 1);
}
}
}
}
}
updateSheet();
for (Rules r : actualTest.getRules()) {
System.out.println(r.getSuccess());
}
}
use of eu.tn.model.Sentences in project TNCY-English-Project by mrngg.
the class AnswerSheetController method initialize.
@FXML
public void initialize() {
actualRules = actualTest.randomRules().getName();
for (Rules r : actualTest.getRules()) {
if (r.getName().equals(actualRules)) {
r.setVisited(true);
actualSentences = r.randomSentences().getName();
for (Sentences s : r.getSentences()) {
if (s.getName().equals(actualSentences)) {
s.setVisited(true);
}
}
}
}
sentences.setText(actualSentences);
}
use of eu.tn.model.Sentences in project TNCY-English-Project by mrngg.
the class DbRulesController method removeSentences.
public void removeSentences() throws IOException {
if (availableRules.getSelectionModel().getSelectedItem() != null && rulesSentences.getSelectionModel().getSelectedItem() != null) {
int j = 0;
int i = 0;
for (Rules r : rules) {
if (r.getName().equals(availableRules.getSelectionModel().getSelectedItem().toString())) {
j = rules.indexOf(r);
for (Sentences s : r.getSentences()) {
if (s.getName().equals(rulesSentences.getSelectionModel().getSelectedItem().toString())) {
i = r.getSentences().indexOf(s);
}
}
}
}
rules.get(j).getSentences().remove(i);
ObservableList<String> items = FXCollections.observableArrayList();
for (i = 0; i < rules.size(); i++) {
items.add(rules.get(i).getName());
}
availableRules.setItems(items);
ObservableList<String> itemS = FXCollections.observableArrayList();
for (i = 0; i < rules.get(j).getSentences().size(); i++) {
itemS.add(rules.get(j).getSentences().get(i).getName());
}
rulesSentences.setItems(itemS);
sentencesName.setText("");
sentencesAnswer.setText("");
new Database().save();
}
}
Aggregations