summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jrummikub/JRummikub.java3
-rw-r--r--src/jrummikub/control/ITurnTimer.java13
-rw-r--r--src/jrummikub/control/TurnControl.java2
-rw-r--r--src/jrummikub/control/TurnTimer.java8
4 files changed, 23 insertions, 3 deletions
diff --git a/src/jrummikub/JRummikub.java b/src/jrummikub/JRummikub.java
index 5ea5a26..945ac5d 100644
--- a/src/jrummikub/JRummikub.java
+++ b/src/jrummikub/JRummikub.java
@@ -8,6 +8,7 @@ import java.util.Map;
import javax.swing.UIManager;
+import jrummikub.control.ITurnTimer;
import jrummikub.control.TurnTimer;
import jrummikub.model.Position;
import jrummikub.model.Stone;
@@ -34,7 +35,7 @@ public class JRummikub {
final IView view = new jrummikub.view.impl.View();
view.setCurrentPlayerName("Player 1");
- TurnTimer testTimer = new TurnTimer(view);
+ ITurnTimer testTimer = new TurnTimer(view);
testTimer.startTimer();
view.getTablePanel().setLeftPlayerName("Player 2");
view.getTablePanel().setTopPlayerName("Player 3");
diff --git a/src/jrummikub/control/ITurnTimer.java b/src/jrummikub/control/ITurnTimer.java
new file mode 100644
index 0000000..54f00b5
--- /dev/null
+++ b/src/jrummikub/control/ITurnTimer.java
@@ -0,0 +1,13 @@
+package jrummikub.control;
+
+import jrummikub.util.IEvent;
+
+public interface ITurnTimer {
+
+ public abstract void startTimer();
+
+ public abstract void stopTimer();
+
+ public abstract IEvent getTimeRunOutEvent();
+
+} \ No newline at end of file
diff --git a/src/jrummikub/control/TurnControl.java b/src/jrummikub/control/TurnControl.java
index ba2c0bb..c994ca1 100644
--- a/src/jrummikub/control/TurnControl.java
+++ b/src/jrummikub/control/TurnControl.java
@@ -10,7 +10,7 @@ import jrummikub.view.IView;
public class TurnControl {
private Hand hand;
private ITable table;
- private TurnTimer timer;
+ private ITurnTimer timer;
private IView view;
private Event endOfTurnEvent = new Event();
diff --git a/src/jrummikub/control/TurnTimer.java b/src/jrummikub/control/TurnTimer.java
index 9e694f7..789bf1a 100644
--- a/src/jrummikub/control/TurnTimer.java
+++ b/src/jrummikub/control/TurnTimer.java
@@ -9,7 +9,7 @@ import jrummikub.util.Event;
import jrummikub.util.IEvent;
import jrummikub.view.IView;
-public class TurnTimer implements ActionListener {
+public class TurnTimer implements ActionListener, ITurnTimer {
private IView view;
private int timeLeft = 60;
private Timer timer;
@@ -23,14 +23,19 @@ public class TurnTimer implements ActionListener {
view.getPlayerPanel().setTimeLeft(timeLeft);
}
+
+ @Override
public void startTimer() {
timer.start();
}
+
+ @Override
public void stopTimer() {
timer.stop();
}
+
@Override
public void actionPerformed(ActionEvent arg0) {
timeLeft--;
@@ -41,6 +46,7 @@ public class TurnTimer implements ActionListener {
}
}
+ @Override
public IEvent getTimeRunOutEvent() {
return timeRunOutEvent;
}