Hongqing Liu | fd5ee81 | 2014-05-10 16:32:51 +0800 | [diff] [blame] | 1 | <!--
|
| 2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
| 3 | contributor license agreements. See the NOTICE file distributed with
|
| 4 | this work for additional information regarding copyright ownership.
|
| 5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
| 6 | (the "License"); you may not use this file except in compliance with
|
| 7 | the License. You may obtain a copy of the License at
|
| 8 |
|
| 9 | http://www.apache.org/licenses/LICENSE-2.0
|
| 10 |
|
| 11 | Unless required by applicable law or agreed to in writing, software
|
| 12 | distributed under the License is distributed on an "AS IS" BASIS,
|
| 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 14 | See the License for the specific language governing permissions and
|
| 15 | limitations under the License.
|
| 16 |
|
| 17 | Number Guess Game
|
| 18 | Written by Jason Hunter, CTO, K&A Software
|
| 19 | http://www.servlets.com
|
| 20 | -->
|
| 21 |
|
| 22 | <%@ page import = "num.NumberGuessBean" %>
|
| 23 |
|
| 24 | <jsp:useBean id="numguess" class="num.NumberGuessBean" scope="session"/>
|
| 25 | <jsp:setProperty name="numguess" property="*"/>
|
| 26 |
|
| 27 | <html>
|
| 28 | <head><title>Number Guess</title></head>
|
| 29 | <body bgcolor="white">
|
| 30 | <font size=4>
|
| 31 |
|
| 32 | <% if (numguess.getSuccess()) { %>
|
| 33 |
|
| 34 | Congratulations! You got it.
|
| 35 | And after just <%= numguess.getNumGuesses() %> tries.<p>
|
| 36 |
|
| 37 | <% numguess.reset(); %>
|
| 38 |
|
| 39 | Care to <a href="numguess.jsp">try again</a>?
|
| 40 |
|
| 41 | <% } else if (numguess.getNumGuesses() == 0) { %>
|
| 42 |
|
| 43 | Welcome to the Number Guess game.<p>
|
| 44 |
|
| 45 | I'm thinking of a number between 1 and 100.<p>
|
| 46 |
|
| 47 | <form method=get>
|
| 48 | What's your guess? <input type=text name=guess>
|
| 49 | <input type=submit value="Submit">
|
| 50 | </form>
|
| 51 |
|
| 52 | <% } else { %>
|
| 53 |
|
| 54 | Good guess, but nope. Try <b><%= numguess.getHint() %></b>.
|
| 55 |
|
| 56 | You have made <%= numguess.getNumGuesses() %> guesses.<p>
|
| 57 |
|
| 58 | I'm thinking of a number between 1 and 100.<p>
|
| 59 |
|
| 60 | <form method=get>
|
| 61 | What's your guess? <input type=text name=guess>
|
| 62 | <input type=submit value="Submit">
|
| 63 | </form>
|
| 64 |
|
| 65 | <% } %>
|
| 66 |
|
| 67 | </font>
|
| 68 | </body>
|
| 69 | </html>
|