summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIda Massow <massow@informatik.uni-luebeck.de>2011-05-04 16:54:30 +0200
committerIda Massow <massow@informatik.uni-luebeck.de>2011-05-04 16:54:30 +0200
commite3e0e301a38e134ebb71e9a7905f76ff65dc4110 (patch)
tree8fe6fe54ee551c8ff4dfe29946b57976ef463dab
parent614d0935be71708331c9b1d65f430d6bf5b00777 (diff)
downloadJRummikub-e3e0e301a38e134ebb71e9a7905f76ff65dc4110.tar
JRummikub-e3e0e301a38e134ebb71e9a7905f76ff65dc4110.zip
Turn Timer hat ein Interface
git-svn-id: svn://sunsvr01.isp.uni-luebeck.de/swproj13/trunk@107 72836036-5685-4462-b002-a69064685172
-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;
}