中小学数学试卷自动生成程序-队友代码分析
中小学数学试卷自动生成程序-对王成龙同学代码的评价
今天开始了结对编程项目,在开展结对编程项目之前我们需要对队友编写的个人项目进行点评。本程序的用户群体为小学、初中和高中数学老师,需要通过控制台的输入完成试卷生成。
王成龙同学的优点:
1.相较于C/C++语言,编码采用了更加方便的Java语言,对于多种异常情况,可以使用捕捉异常函数,确保了程序运行的稳定性。
2.文本文件生成函数编写流畅,结构清晰,修改方便。
File file = new File("src/Frame/"+path+"\\copy.txt");
if(!file.exists())
{
try {
file.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}
}
Set<String> set = new HashSet<String>();
try {
FileReader fr = new FileReader("src/Frame/"+path+"/copy.txt");
BufferedReader bf = new BufferedReader(fr);
String str;
while((str = bf.readLine())!= null)
{
String[] temper = str.split(" ");
if(temper.length==2)
{
str = temper[1];
set.add(str);
}
}
bf.close();
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
3.生成题目的函数部分逻辑清晰,附加的注释简洁明了,易于识别。
if(type.equals("初中") || type.equals("高中")) //加上平方和根号 num个二元操作符 num+1个操作数
{
int base = 0;
for (int j=0;j<temp.length()-1;j++)
{
if(temp.charAt(j) == '(') //根号- 左括号左边 / 二元操作数右边 //平方- 二元操作数左边/ 右括号右边
{
if(base==0)
{
temp = temp.substring(0,j) + "√" + temp.substring(j);
base++;
}
int flag = (int)(0+Math.random()*(10-0+1));
if(flag==1)
temp = temp.substring(0,j) + "√" + temp.substring(j);
}
.......
4.用户体验好,在程序运行的过程中,出现了很多提示性的话语,这些提示语就能告诉用户在运行到不同阶段时应该输入的不同操作,形成一个引导的功能,也可以通过这个了解到程序此时正在执行的操作,以及相关操作是否成功。
王成龙同学的缺点:
1.代码编写方式有点问题,略显杂乱,部分代码的注释也偏少。
2.初始化函数有一些冗余,并且有的地方有部分多余的代码。
public class Account {
private String type = new String();
private String ID = new String();
private String pwd = new String();
......
3.随机生成算术的时候,任然偶尔会出现一些无意义的括号,虽然符合算术结果的规律,不过不太美观,影响用户的体验。

浙公网安备 33010602011771号