结对编程1-模块化
项目Coding.net地址:https://git.coding.net/hotace_c/MyExercisesCreater.git
队伍成员:李胜昌
需求分析:
代码展示
输出算式:
<form action="SubmitServlet" method="post">
<%
LinkedList<Equation> equations=(LinkedList<Equation>)session.getAttribute( "equations" );
int index=Integer.parseInt( request.getParameter( "index" ));
%>
<input type="hidden" name="index" value="<%=index %>">
<div align="center">
<h2>第<%=index+1 %>题</h2>
<%=equations.get( index ) %>=
<input type="text" name="answer" />
</div>
<%
if(index==(equations.size()-1)){
%>
<div align="center"><input type="submit" value="完成提交"></div>
<%
}else{
%>
<div align="center"><input type="submit" value="下一题"></div>
<%
}
%>
</form>
展示结果:
<div align="center">
<%
LinkedList<Equation> equations=(LinkedList<Equation>)session
.getAttribute( "equations" );
LinkedHashMap<Equation, Fraction> eaMap = (LinkedHashMap<Equation, Fraction>)request
.getSession().getAttribute( "eaMap" );
for(int i=0;i<equations.size();i++){
Equation equation=equations.get( i );
%>
<div>
<%=i+1 %>.
<%=equations.get( i ) %>
正确答案<input type="text" value="<%=equation.getAnswer() %>" disabled="disabled">
您的答案<input type="text" value="<%=eaMap.get( equation )==null?' ':eaMap.get( equation ) %>" disabled="disabled">
<%
if(equation.getAnswer().equals( eaMap.get( equation ))){
%>
<img src="pic/正确.png">正确
<%
}else{
%>
<img src="pic/错误.png">错误
<%
}
%>
<br/>
</div>
<%
}
%>
程序运行
小结感受
进一步优化了程序,使其更具有实用性
PSP