Search in sources :

Example 1 with Sentences

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();
    }
}
Also used : Button(javafx.scene.control.Button) Scene(javafx.scene.Scene) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) Rules(eu.tn.model.Rules) IOException(java.io.IOException) Tests(eu.tn.model.Tests) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) Stage(javafx.stage.Stage) FXMLLoader(javafx.fxml.FXMLLoader) Sentences(eu.tn.model.Sentences) BorderPane(javafx.scene.layout.BorderPane) BorderPane(javafx.scene.layout.BorderPane) Sentences(eu.tn.model.Sentences) Stage(javafx.stage.Stage) Scene(javafx.scene.Scene) Rules(eu.tn.model.Rules) FXMLLoader(javafx.fxml.FXMLLoader)

Example 2 with Sentences

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();
    }
}
Also used : Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules)

Example 3 with Sentences

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());
    }
}
Also used : Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules)

Example 4 with Sentences

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);
}
Also used : Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules) FXML(javafx.fxml.FXML)

Example 5 with Sentences

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();
    }
}
Also used : Database(eu.tn.model.Database) Sentences(eu.tn.model.Sentences) Rules(eu.tn.model.Rules)

Aggregations

Rules (eu.tn.model.Rules)8 Sentences (eu.tn.model.Sentences)8 Database (eu.tn.model.Database)3 IOException (java.io.IOException)3 Scene (javafx.scene.Scene)3 Button (javafx.scene.control.Button)3 Label (javafx.scene.control.Label)3 TextField (javafx.scene.control.TextField)3 Stage (javafx.stage.Stage)3 FXML (javafx.fxml.FXML)2 Insets (javafx.geometry.Insets)2 GridPane (javafx.scene.layout.GridPane)2 Tests (eu.tn.model.Tests)1 Platform (javafx.application.Platform)1 FXMLLoader (javafx.fxml.FXMLLoader)1 BorderPane (javafx.scene.layout.BorderPane)1