From 3e48c5d7eb08a2cfbb277b0fc098a48016f3047e Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Sun, 12 Jun 2016 15:01:37 +0200 Subject: [PATCH] Test: no direct repetitions --- src/main/java/es/kauron/jstudy/controller/TestController.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/es/kauron/jstudy/controller/TestController.java b/src/main/java/es/kauron/jstudy/controller/TestController.java index 0703406..70c0f75 100644 --- a/src/main/java/es/kauron/jstudy/controller/TestController.java +++ b/src/main/java/es/kauron/jstudy/controller/TestController.java @@ -69,7 +69,9 @@ public class TestController implements Initializable { private void onSkipAction(ActionEvent event) { feedback.setVisible(AppConfig.showFeedback); answer.setText(""); - current = (int) (Math.random() * list.size()); + int previous = current; + while (list.size() > 1 && current == previous) + current = (int) (Math.random() * list.size()); question.setText(list.get(current).getQuestion()); answer.requestFocus(); }