运用Session的猜数字游戏
来源:互联网 发布:mmd绅士动作数据 编辑:程序博客网 时间:2024/06/06 00:05
运用session保存数据
guess1.jsp
<body> <a href="guess2.jsp">去玩猜数字游戏</a> <% int i=(int)(Math.random()*100+1); session.setAttribute("number", 1); session.setAttribute("count", 0); %> </body>
guess2.jsp
<body> 请输入你猜的数字: <form action="guess3.jsp"> <input type="text" name="n"> <input type="submit" value="guess"> </form> </body>
guess3.jsp
<body> <% String str=request.getParameter("n"); int number=Integer.parseInt(str); int trueN=(Integer)session.getAttribute("number"); int count=(Integer)session.getAttribute("count"); count++; session.setAttribute("count", count); if(number>trueN){ out.print("猜大了,这是第"+count+"次,返回继续----》"); out.print("<a href='guess2.jsp'>=====</a>"); }else if(number>trueN){ out.print("猜小了,这是第"+count+"次,返回继续----》"); out.print("<a href='guess2.jsp'>=====</a>"); }else{ out.print("猜对了,一共花了"+count+"次"); } %> </body>
0 0
- 运用Session的猜数字游戏
- Session猜数字游戏
- 利用内置变量session做的猜数字游戏游戏
- 猜数字的游戏
- 猜数字的游戏(GuessNumber)
- 猜数字游戏的实现
- 猜数字游戏的实现
- 猜数字游戏的实现
- 猜数字游戏的提示
- 猜数字游戏的提示
- 一个猜数字的游戏
- 猜数字的游戏Python3
- 随机数的猜数字游戏
- 猜数字游戏的提示
- 一个猜数字游戏的算法
- 一个猜数字的游戏(源代码)
- 解猜数字游戏的程序
- 文曲星上的猜数字游戏程序
- android开发 极光推送继承 demo
- HTML表格动态增加一行/删除/修改
- mysql中char与varchar的区别分析
- Android NDK 开发无法导入第三方so问题
- 互联网广告系统综述七特征
- 运用Session的猜数字游戏
- Windows驱动开发好用链接
- Service里常驻Notification,可以在后台低内存的时候不被kill
- 使用Log4Net - 文件日志
- C++类静态成员与类静态成员函数
- 设计模式总结(1)之设计模式分类
- 自己写BootLoader
- Defaultbeanfactory, check_charset 备忘
- javascript 对象、面向对象、变量和属性的关系