设计思想
随机生成数字和符号,判断结果100以内算式输出,
代码
package 四则运算1; import java.*; import java.util.Random; import org.omg.CORBA.PRIVATE_MEMBER; public class YunSuan { static private int num1; static private int num2; static private int num3; static private int fh1; static private int fh2; static private int titlenum; static private int t; static private int f; static private int w; static private int answer[]; static private String title[]; public int getNum1() { return num1; } public void setNum1(int num1) { this.num1 = num1; } public int getNum2() { return num2; } public void setNum2(int num2) { this.num2 = num2; } public int getNum3() { return num3; } public void setNum3(int num3) { this.num3 = num3; } public int getFh1() { return fh1; } public void setFh1(int fh1) { this.fh1 = fh1; } public int getFh2() { return fh2; } public void setFh2(int fh2) { this.fh2 = fh2; } public int getT() { return t; } public void setT(){ t++; } public int getF() { return f; } public void setF() { f++; } public int getW() { return w; } public void setW() { w++; } public String[] getTitle() { return title; } public void setTitle(String[] title) { this.title = title; } public int[] getAnswer() { return answer; } public void setAnswer(int answer[]) { this.answer = answer; } public void fuzhi(int n) { Random rd=new Random(); String title[] = new String[n]; int answer[]=new int[n]; for(int i=0;i<n;i++) { setNum1(rd.nextInt(100)+1); setNum2(rd.nextInt(100)+1); setNum3(rd.nextInt(100)+1); setFh1(rd.nextInt(4)); setFh2(rd.nextInt(4)); if(getFh1()<2&&getFh2()<2) { if(getFh1()==0&&getFh2()==0) { int daan=getNum1()+getNum2()+getNum3(); if(answer[i]<=100) { answer[i]=daan; title[i]=getNum1()+"+"+getNum2()+"+"+getNum3(); } else { i--; } } else if(getFh1()==0&&getFh2()==1) { int daan=getNum1()+getNum2()-getNum3(); if(daan>=0&&daan<=100) { answer[i]=daan; title[i]=getNum1()+"+"+getNum2()+"-"+getNum3(); } else { i--; } } else if(getFh1()==1&&getFh2()==0) { int daan=getNum1()-getNum2()+getNum3(); if(daan>=0&&daan<=100) { answer[i]=daan; title[i]=getNum1()+"-"+getNum2()+"+"+getNum3(); } else { i--; } } else if(getFh1()==1&&getFh2()==1) { int daan=getNum1()-getNum2()-getNum3(); if(daan>=0&&daan<=100) { answer[i]=daan; title[i]=getNum1()+"-"+getNum2()+"-"+getNum3(); } else { i--; } } } else { if(getFh1()==0) { int daan=getNum1()+getNum2(); if(daan<=100) { answer[i]=daan; title[i]=getNum1()+"+"+getNum2(); } else { i--; } } else if(getFh1()==1) { int daan=getNum1()-getNum2(); if(daan>=0) { answer[i]=daan; title[i]=getNum1()+"-"+getNum2(); } else { i--; } } else if(getFh1()==2) { setNum1(rd.nextInt(10)+1); setNum2(rd.nextInt(10)+1); answer[i]=getNum1()*getNum2(); title[i]=getNum1()+"*"+getNum2(); } else if(getFh1()==3) { if(getNum1()%getNum2()==0) { answer[i]=getNum1()/getNum2(); title[i]=getNum1()+"/"+getNum2(); } else { i--; } } } setAnswer(answer); setTitle(title); } } public static void main(String[] args) { YunSuan ys=new YunSuan(); ys.fuzhi(1000); } }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>四则运算1</title> </head> <body > <form action="page.jsp" method="get"> <center >四则运算</center> <br> <br> <h1 > 出题数量 <input type="text" name="number" /><%=request.getAttribute("error")%></h1> <br> //<h1 > 答题时间(秒) <input type="text" name="time" /><%=request.getAttribute("error")%></h1> <br> <center><input type="submit" value="确定" /></center> </form> </body> </html>
<%@page import="四则运算1.YunSuan"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>四则运算</title> </head> <body > <form action="page2.jsp" method="get"> <center >四则运算</center> <br> <br> <% String num=request.getParameter("number"); String time=request.getParameter("time"); if(num == null || "".equals(num.trim())||time == null || "".equals(time.trim())){ request.setAttribute("error", "这一行不能为空"); %> <jsp:forward page="choose.jsp"></jsp:forward> <% } int number=Integer.parseInt(num); int time2=Integer.parseInt(time); YunSuan ys=new YunSuan(); ys.fuzhi(number); int t=time2*1000; %> <!-- <script language='javaScript' > setTimeout("alert('时间到了!')",<%=t%>)</script> --> <center>时间已经过去:<span id=id2>0</span>秒;<%=time2 %>秒后系统自动提交。</center>> <script language="javascript"> var i=0; function showtime(){ i=i+1; id2.innerHTML=i; setTimeout("showtime()",1000); if(i==<%=time2%>) document.forms[0].submit(); } showtime(); </script> <br> <br> <% for(int i=0;i<number;i++) { %> <h1 style="margin-left:360px;font-family:楷体;font-size:15px"> <%=ys.getTitle()[i]%> <input type="text" name=<%=i %>/></h1> <br> <% } %> <center><input type="submit" value="提交" /></center> <br> <center><a href="###"><input type="button" value="退出" /></a></center> </form> </body> </html>
<%@page import="java.util.*"%> <%@page import="四则运算1.YunSuan"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>四则运算</title> </head> <body > <center style="color:red ; font-family:华文行楷;font-size:35px">四则运算</center> <br> <br> <% YunSuan ys=new YunSuan(); int i=0; Enumeration pNames=request.getParameterNames(); while(pNames.hasMoreElements()){ String name=(String)pNames.nextElement(); String value=request.getParameter(name); if(value == null || "".equals(value)) { request.setAttribute("error", "未做"); ys.setW(); %> <h1 style="margin-left:360px;font-family:楷体;font-size:15px"> <%=ys.getTitle()[i]%> <input type="text" name=<%=i %> value=<%=request.getAttribute("error")%>>× 正确答案为:<%=ys.getAnswer()[i] %></h1> <% } else { int answer=Integer.parseInt(value); if(ys.getAnswer()[i]==answer) { ys.setT(); %> <h1 style="margin-left:360px;font-family:楷体;font-size:15px"> <%=ys.getTitle()[i]%> <input type="text" name=<%=i %> value=<%=answer %>>√</h1> <br> <% } else { ys.setT(); %> <h1 style="margin-left:360px;font-family:楷体;font-size:15px"> <%=ys.getTitle()[i]%> <input type="text" name=<%=i %> value=<%=answer %>>× 正确答案为:<%=ys.getAnswer()[i] %></h1> <br> <% } } i++; } %> <br> <h1 style="margin-left:360px;font-family:楷体;font-size:20px;color:red"> 共答对<%=ys.getT() %>题</h1> <h1 style="margin-left:360px;font-family:楷体;font-size:20px;color:red"> 共答错<%=ys.getF() %>题</h1> <h1 style="margin-left:360px;font-family:楷体;font-size:20px;color:red"> 未答<%=ys.getW() %>题</h1> </body> </html>
截图
时间记录日历
Personal Software Process Stages |
Time |
计划 |
|
估计这个任务多长时间 |
4个小时 |
开发 |
|
需求分析 |
20分钟 |
生成设计文档 |
10分钟 |
设计复审 |
|
代码规范 |
20分钟 |
具体设计 |
20分钟 |
具体编码 |
2小时 |
代码复审 |
30分钟 |
测试 |
1小时 |
报告 |
|
测试报告 |
|
计算工作量 |
|
事后总结,并提出过程改进计划 |
1小时 |
合计 |
8小时40分钟 |
测试用例
测试能否使用,提交是否正常。