01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: Success.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package tutorial.numberguess;
09:
10: import com.uwyn.rife.engine.Element;
11: import com.uwyn.rife.template.Template;
12: import tutorial.numberguess.backend.Contest;
13: import tutorial.numberguess.backend.Game;
14:
15: /**
16: * This element outputs the results of a played game when the number was
17: * successfully guessed. The active game is stopped.
18: *
19: * @author Geert Bevin (gbevin[remove] at uwyn dot com)
20: * @version $Revision: 3634 $
21: */
22: public class Success extends Element {
23: /**
24: * The element's entry point.
25: */
26: public void processElement() {
27: // stop the active game and retrieve its details
28: Game game = Contest.stopGame(getInput("gameid"));
29: // if no game was active, start a new one
30: if (null == game) {
31: exit("start");
32: }
33:
34: // output the details of the played game
35: Template template = getHtmlTemplate("success");
36:
37: template.setValue("answer", game.getAnswer());
38: template.setValue("guesses", game.getGuesses());
39: template.setValue("duration", game.getDuration());
40:
41: print(template);
42: }
43: }
|