码迷,mamicode.com
首页 > Web开发 > 详细

四则运算网页版

时间:2017-04-10 00:49:12      阅读:299      评论:0      收藏:0      [点我收藏+]

标签:turn   pat   nal   question   title   code   1.4   private   负数   

合作人:张保海 胡泽杰

技术分享
public  HandleRequest chuti(HandleRequest handleRequest){
        
        //有乘除法
        if(handleRequest.getChengchufa()){
            //有余数
            if(handleRequest.getShifuyushu()){
                //有负数
                if(handleRequest.getShifufushu()){
                    //有余有负
                    return getchengchumeiyuyoufu(handleRequest);
                }else{
                    //有余没负
                    return getchengchuyouyumeifu(handleRequest);
                }
                
            }
            //没有余数
            else{
                
                if(handleRequest.getShifufushu()){
                    //没有余数 有负数
                    return getchengchumeiyuyoufu(handleRequest);
                }else{
                    return getchengchumeiyumeifu(handleRequest);
                }
            }
            
         }//没有乘除
        else{
            if(handleRequest.getShifufushu()){
                return getjiajianyoufu(handleRequest);
            }else{
                return getjiajianmeifu(handleRequest);
            }
        }
        
    }

QusetionAction.java
HandleRequest chuti
技术分享
public class HandleRequest implements Serializable {
    private  Boolean  chengchufa;//是否有乘除法
    private  Boolean  shifuyushu;//是否有余数
    private  Boolean  shifufushu;//是否有负数
    private  int    questnum=10;  //题目数量
    private  int    maxnum=10;//整数的取值范围
    
    private  int    correctresultnum;//正确题目数量
    private  List<Questions> qusetions;//题目集合

HandleRequest.java
HandleRequest implements Serializable
技术分享
public class Questions implements Serializable{
    private  int  id;//题目号
    private  float fistnum;//第一个数字
    private  String fuhao;//运算符号
    private  float secondnum;//第二个数字
    private  float  correctresult; //正确结果
    private  float  inputresult;//输入结果
    private  int inputyushu; //输入余数
    
    private  int  yushu;//余数

Questions.java
Questions implements Serializable
技术分享
public  HandleRequest chuti(HandleRequest handleRequest){
        
        //有乘除法
        if(handleRequest.getChengchufa()){
            //有余数
            if(handleRequest.getShifuyushu()){
                //有负数
                if(handleRequest.getShifufushu()){
                    //有余有负
                    return getchengchumeiyuyoufu(handleRequest);
                }else{
                    //有余没负
                    return getchengchuyouyumeifu(handleRequest);
                }
                
            }
            //没有余数
            else{
                
                if(handleRequest.getShifufushu()){
                    //没有余数 有负数
                    return getchengchumeiyuyoufu(handleRequest);
                }else{
                    return getchengchumeiyumeifu(handleRequest);
                }
            }
            
         }//没有乘除
        else{
            if(handleRequest.getShifufushu()){
                return getjiajianyoufu(handleRequest);
            }else{
                return getjiajianmeifu(handleRequest);
            }
        }
        
    }

QuestionService.java
HandleRequest chuti
技术分享
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script language="javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.2.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/js/test.js"></script>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP ‘chuti.jsp‘ starting page</title>
    
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
   <style type="text/css">
      input[name="correct"]:{
          border: none;
      },
      #questnum1:{
         visibility: hidden;
      }
   </style>
  </head>
  
  <body background="images/bk.jpg">
    <div align="center">
              题目数量<input type="text" id="questnum" value="${handlerequest.questnum }" disabled>
     <p>
    <s:iterator value="#questions" id="questions"><s:property value="id"/>题:<s:property value="fistnum"/><s:property value="fuhao"/><s:property value="secondnum"/>=<input type="text" name="inputresult" id="${id }inputresult"><input  name="correct" value="正确答案" disabled><input type="text" name="correctresult" value="${correctresult }" id="${id}correctresult"/><p>
    </s:iterator>
    <input type="button" id="panduan" value="判断">
     <input type="button" id="returnindex" value="回到主页">
    </div>
    <div align="center" id="questnum1">
       正确题目数: <input type="text"  name="correctnum" id="corrextnum" disabled >
    </div>
  </body>
</html>

chuti.jsp
index.html
技术分享
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<script language="javascript" src="${pageContext.request.contextPath}/js/jquery-1.4.2.js"></script>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>二柱子测试平台</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">    
    <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    <meta http-equiv="description" content="This is my page">
    <script language="javascript" src="js/jquery-1.4.2.js"></script>
    <script language="javascript" src="js/test.js"></script>
    <!--
    <link rel="stylesheet" type="text/css" href="styles.css">
    -->
    <style type="text/css">
      #question{
      visibility: hidden;
      background: gray;
      }
    </style>
    <script type="text/javascript">
    
    
    </script>
  </head>
  
  <body background="images/bk.jpg">
  
  <div  id="welcome" align="center">
     <h1>欢迎来到二柱子测试平台</h1>
  </div>
  <div id="select" align="center">
  
 <s:form action="questionAction_chuti.action">
 <p>乘除法:<input type="checkbox" name="chengchufa" id="chengchufa" value=true></input> </p>
 <p>是否有余数:<input type="checkbox" name="shifuyushu" id="shifuyushu" value=true></input></p>
 <p> 是否有负数:<input type="checkbox" name="shifufushu" id="shifufushu" value=true></input></p>
 <p> 题目数量:<input type="text" name="questnum" id="questnum"></input></p>
 <p>整数最大值:<input type="text" name="maxnum" id="maxnum"></input></p>
 <input type="submit" value="提交">
  </s:form>
  </div>
 
  </body>
</html>

index.jsp
index

实验截图:

技术分享

技术分享

小组总结:

运用到了java web 所学的知识,学以致用,收获很多

 

四则运算网页版

标签:turn   pat   nal   question   title   code   1.4   private   负数   

原文地址:http://www.cnblogs.com/zhangbaohai/p/6686990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!