Pair programming - the program automatically generated based on primary and secondary school mathematics papers JAVA development

  Two weeks, based on primary and secondary students participated in the mathematics papers personal items automatically generating program and pair programming project I Tan classmates. Knot to achieve the program is based on the individual programming, but because I am using c ++ and companion is used PYTHON After our discussion we decided to start to write JAVA, the whole process workload is very large, it took a long time to complete the project. The method is essentially the topic draws on previous ideas, but twinning project with the new requirements, we also think of ways to meet the needs of one by one after the update. My companion is responsible for all parts of the interface and the interface Ali cloud messaging services. Before that my JAVA foundation is actually very weak, thank Tan has been to help the students to explain.

       The first is part of a personal project that does not require the calculation formula results only need to generate the equation. But the pair programming is required to produce the final score, which means that we need to compare the results of the equation and multiple-choice answers, I learned JAVA in fact, there is a function of the calculation formula, but a formula is not the beginning that we generate can be calculated out of the norm formula, it takes a lot of effort into JAVA in how the equation can be directly calculated, for example, we need to get rid of the equation equal sign, and then we use daily habits but can not be identified (such as the 2 ^ class) into equation may be calculated, which is the most difficult trigonometric SiN, and calculates cos tan, but the good news was bracketed reference pairing rules successfully resolved.

// I think this is very clever pairing achieve brackets, braces and other operators will create a string array, which defines the number leftbra and rightbra two variables to calculate the left and right parentheses, in order to achieve a match between brackets

Random ran=new Random();
for(int i=0;i<num;i++)
{
for(int j=0;j<ran.nextInt(4)+1;j++)
{
int rannum=ran.nextInt(5);
if(rannum==5)
{
rannum=rannum-2;
}
else if(rannum<=3)
{
System.out.print(num1[ran.nextInt(100)]);
}
System.out.print(str[rannum]);
if(rannum==4)
{
System.out.print(num1[ran.nextInt(100)]);
System.out.print(str[rannum-ran.nextInt(3)-1]);
}
if(rannum==4)
{
leftbra++;
}
else if(rannum==5)
{
rightbra++;
}
}
System.out.print(num1[ran.nextInt(100)]);
while(leftbra>rightbra)
{
System.out.print(str[5]);
rightbra++;
}
System.out.println("=");

}

 

// this is a small part of the code conversion formula

while((str=br1.readLine())!=null)
{
str=str.replaceAll("Math.sin", "sin");
str=str.replaceAll("Math.cos", "cos");
str=str.replaceAll("Math.tan", "tan");
str=str.replaceAll("Math.pow\\(", "(");
str=str.replaceAll(",0.5\\)", ")^0.5");
str=str.replaceAll(",2\\)", ")^2");
System.out.println(str);
}                                              

 

As for the choice of each answer, we are taken randomly generated number after the plus or minus a small range as the wrong answer to the right answer, based on the so enhances the rationality of the subject.

       After making the interface also encountered some problems, such as in the case of considering how the confidentiality of the password can not be transformed into asterisk displayed. I looked up the relevant information and found that you can call .setEchoChar ( '*') to solve this problem. But after a call only to find the original text input box "Enter Password" prompt text has become a star, it makes me laugh and cry. And then weigh after partner, we finally did not accept the result of the changes, but retains the previous interface, which is part of the code is insufficient, time can be corrected in the future.

       The final step is to modify the password function. Due to lack of database-related knowledge base, our code is to use a text file to store user data. It would also be able to achieve the basic functions, but it is regrettable that our code appeared BUG, ​​if there are two user passwords are the same, change a user's password which will get rid of the other user's password. So far we have not been able to solve this BUG, ​​which can be considered our project at the junction of the programming deficiencies.

       Generally speaking, I benefited from the process of programming the knot. Before there have been few experiences to do the project, to build a little bit like this, the final product came out really strong sense of satisfaction. Thanks to the hard work of partner again, from whom I have learned a lot of ways to solve the problem.

Guess you like

Origin www.cnblogs.com/kisaragi11037/p/11605021.html
Recommended