Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Question {
- private SimpleStringProperty question;
- private String[] possibleAnswers;
- private SimpleIntegerProperty indexOfCorrectAnswer;
- private int numberCorrectAnswers;
- private int gegebeneAntworten;
- private int richtigeAntworten;
- public Question(String question, String[] possibleAnswers, int indexOfCorrectAnswer) {
- if (indexOfCorrectAnswer < 0 || indexOfCorrectAnswer >= possibleAnswers.length) {
- throw new IllegalArgumentException();
- }
- this.question = new SimpleStringProperty(question);
- this.possibleAnswers = possibleAnswers;
- this.indexOfCorrectAnswer = new SimpleIntegerProperty(indexOfCorrectAnswer);
- gegebeneAntworten = 0;
- richtigeAntworten = 0;
- }
- public SimpleStringProperty getQuestion() {
- return question;
- }
- public String correctAnswer() {
- return possibleAnswers[indexOfCorrectAnswer];
- }
- public String toString() {
- return question + " (Antworten: " + gegebeneAntworten + ", davon richtig: " + richtigeAntworten + ")";
- }
- public String[] getPossibleAnswers() {
- return possibleAnswers;
- }
- public void erhoeheAntwort() {
- gegebeneAntworten++;
- }
- public void erhoeheRichtigeAntwort() {
- richtigeAntworten++;
- }
- public SimpleIntegerProperty getIndexOfCorrectAnswer() {
- return indexOfCorrectAnswer;
- }
- public int getNumberofCorrectAnswers() {
- return numberCorrectAnswers;
- }
- public void resetAnswer() {
- gegebeneAntworten = 0;
- richtigeAntworten = gegebeneAntworten;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement