Primary and secondary school mathematics papers with UI auto-generation system

[] Project requirements

1, user registration function. The user's phone number, click on the registration will receive a registration code, the user can use this registration code to complete the registration;

2, password setting function, the user enter the password twice to set a password matching success. 6-10 password, the case must contain letters and numbers;

3, modify the password function, enter the correct original password, then enter the same new password twice to change the password successfully;

3, the difficulty selection function, interface shows elementary, middle and high school three options, the user clicks on one of them, prompting the user to enter the number of items need to generation;

4, the number of items the user input, generating a piece of paper (with a roll can not have the same title, all entitled multiple choice), the interface displays the first question and casual working four options, the user selects one of the four options submission interface displays the second question, ... until the last question;

5, the score display function, after the submission of the last question, the display interface, the score is calculated based on the percentage of correct answers;

6, the user interface can opt out of the score or continue to do problems;

7, small initial high demand topic see previous blog

[Needs] and code analysis

1, for user registration functionality of our application template in a text message on Ali cloud after cloud Ali api.jar package by importing the SMS-related, the code sends a request to send a verification code text message;

2, to check the password setting function is a string, the need uppercase, lowercase letters and numbers, and a length of 6-10 bits long. This is what we wrote before OJ title, and set a flag to check whether there are three elements can be; in the case of enter a valid user name and password will be saved to the database;

1  // for registered users 
2  public  Boolean Register (Loginer loginer) {
 . 3          Connection Conn = null ;
 . 4          the PreparedStatement The PSMTs reported = null ;
 . 5          String SQL = "INSERT INTO loginer (name, password, State) values (,,??? ) "; // add new information to the database user 
. 6          the try {
 . 7              Conn = dbhelp.getConnection ();
 . 8              the PreparedStatement pTMT = conn.prepareStatement (SQL);
 . 9              ptmt.setString (. 1 , loginer.getName ());
 10              pTMT .setString (2, loginer.getPassword());
11             ptmt.setInt(3, loginer.getState());
12             ptmt.execute();
13         } catch (Exception e) {
14             e.printStackTrace();
15             return false;
16         }
17         return true;
18     }

3, password change function to find the original password and the original password entered in the corresponding database by matching the current login status corresponding to the user name (name), a password and verify whether the newly set (6-10 password, must contain case letters and numbers) requirements; consistent with the requirements to modify the values ​​of the corresponding fields in the database;

 

1  // get the password of usernames 
2  public String GET (String name) {
 . 3          Connection Conn = null ;
 . 4          the PreparedStatement The PSMTs reported = null ;
 . 5          the ResultSet RS = null ;
 . 6          String password = new new String ();
 . 7          String = SQL " * loginer the WHERE name from the SELECT = ";? // find the appropriate user name of the user 
8          the try {
 9              conn = dbhelp.getConnection ();
 10              PreparedStatement pTMT = conn.prepareStatement (SQL);
11             ptmt.setString(1, name);
12             rs = ptmt.executeQuery();
13             while(rs.next()){
14                 password = rs.getString("password");//获得密码
15             }
16             return password;
17         } catch (Exception e) {
18             e.printStackTrace();
19         }
20         return null;
21     }

 

1  // for changing the password for the user name 
2  public  Boolean Change (Loginer loginer) {
 . 3          Connection Conn = null ;
 . 4          the PreparedStatement The PSMTs reported = null ;
 . 5          String SQL = "Update loginer SET password = WHERE name =??"; / / update the password corresponding to the user name 
. 6          the try {
 . 7              Conn = dbhelp.getConnection ();
 . 8              the PreparedStatement pTMT = conn.prepareStatement (SQL);
 . 9              ptmt.setString (2 , loginer.getName ());
 10              ptmt.setString (. 1, loginer.getPassword());
11             ptmt.execute();
12         } catch (Exception e) {
13             e.printStackTrace();
14             return false;
15         }
16         return true;
17     }

4, in the title part, using a similar method calls itself recursively constructed until the last question, click on the button to trigger the event goes configuration of the display scores window;

[Project] Points

1, graphical interfaces, at the time of preparation of the discovered artifacts --Windows builder plugin for eclipse UI interface design. The plugin we can better layout by dragging the frame and button, text Field and other elements, as well as good design of their size, without the need to code line by line to knock them out and then slowly adjust the interface to see after running size of the element. Here attach others to write an article on Windows builder explain the blog; the interface is configured as shown below, all elements of Swing can be set directly;

 

 

 2, the personal project based on the topic also requires us to give the correct answer to the title of his own generation, but the computer is not one did, in our eyes a simple mathematical formula in the eyes of the computer just a bunch of monotonous string there is no way to calculate the results of this string to the string in case we do not write any logic. Through access to information, found one called Reverse Polish Notation things, it can only contain a string of addition, subtraction and brackets into the formula to calculate the mathematical expression of the results. Such an action would greatly simplify the amount of our thinking. For the primary topic we just need to directly call the reverse Polish notation can be the result, for the case of middle and high school contains a square root, square, trigonometric functions, we need these three things first extracted, call the relevant function Math they converted to digital, then plug it back to the original formula, the formula can be converted into a mathematical formula to calculate the results of the primary school.

Results show]

login interface

 

User interface register, the output of randomly generated codes in the control panel and the feedback information transmitted successfully or not

 

 

 Password verification form

 

 

 The topic Interface

 

 

 Exit Interface

 

[Summary] reflect

Pair programming throughout the long period of 1.5 weeks from the start of the demand for analysis, thinking Solutions, to achieve, in the middle with a lot of the method, the method also gave up a lot. When just beginning to see the need to give the correct answer to this demand, we want to pursue a perfect result, that generates the answer in line with a normal logic, such as for middle and high school title, √45 in the results should be 3√5 instead of a decimal, but in the end because of the time we give up this optimization, after submitting a job can continue to complete it. Then is to call the registration of databases, database calls to save user data registered, the next time to find a match when you log on, replace the corresponding match field when you modify the password, which is actually more than to save user information to txt file thinking more clearly, and also to find a more convenient way to modify the corresponding content. The last is, partner syJ too good, I need to learn more.

 

 

Guess you like

Origin www.cnblogs.com/zhm0424/p/11605461.html
Recommended