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