KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > wap > quiz > Home


1 // Copyright 2004 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14

15 package org.apache.tapestry.wap.quiz;
16
17 import org.apache.tapestry.IRequestCycle;
18 import org.apache.tapestry.form.IPropertySelectionModel;
19 import org.apache.tapestry.form.StringPropertySelectionModel;
20 import org.apache.tapestry.wml.Deck;
21
22 /**
23  * Home deck for the Quiz application.
24  *
25  * Quiz application is a game that is run on a server that people can connect to using a WAP phone.
26  * The game is highly customizable. You can add your own questions to simple text files without
27  * any knowledge of programming.
28  *
29  * @version $Id: Home.java,v 1.3 2004/02/19 17:38:02 hlship Exp $
30  * @author David Solis
31  *
32  **/

33
34 public abstract class Home extends Deck
35 {
36
37     public static final IPropertySelectionModel LEVEL_MODEL = new StringPropertySelectionModel
38             (new String JavaDoc[] { Global.EASY_LEVEL, Global.MEDIUM_LEVEL, Global.HARD_LEVEL });
39     
40     public void start(IRequestCycle cycle)
41     {
42         Global global = (Global) getGlobal();
43         global.initialize(cycle);
44         Visit visit = (Visit) getVisit();
45         String JavaDoc level = getLevel();
46         int questionSet = global.getQuestionSet(level);
47         String JavaDoc username = getUsername();
48         if (username == null || "".equals(username))
49             username = "newcomer";
50         visit.initialize(username, level, questionSet, global.getNumberOfQuestions(questionSet));
51         Quiz quizDeck = (Quiz) cycle.getPage("Quiz");
52         quizDeck.setQuestionNumber(0);
53         quizDeck.fetch();
54         cycle.activate(quizDeck);
55     }
56     
57     public abstract String JavaDoc getUsername();
58     public abstract void setUsername(String JavaDoc username);
59     
60     public abstract String JavaDoc getLevel();
61     public abstract void setLevel(String JavaDoc level);
62 }
63
Popular Tags