Pair programming project analysis and experience summary

Twinning project realization

 

preface

This blog summarizes pair programming based on personal programming, mainly including code reuse and lessons learned from pair programming

Pairing programming division of labor: I am responsible for UI interface (login interface, question setting interface, question making interface, report interface, password modification, pop-up module), and teammates are responsible for (verification code registration module, duplicate checking module, account information saving module, calculation module)

1, Pairing programming requirements

1. All functions are operated through graphical interface, which can be desktop application or website (programming language and technology are not limited);
2. User registration function. The user provides the mobile phone number. Click registration to receive a registration code. The user can use the registration code to complete the registration;
3. After the user completes the registration, the interface prompts to set the password. After the user enters the password twice, the password is set successfully. The password is 6-10 digits and must contain upper and lower case letters and numbers. The user can change the password in the login status, enter the correct original password, and then enter the same new password twice, and the password is changed successfully;
4. After the password is set successfully, jump to the selection interface, which displays three options: primary school, junior middle school and senior high school. After clicking one of them, the user will be prompted to enter the number of questions to be generated;
5. After the user enters the number of questions, a test paper is generated (the same paper cannot have the same questions, and all the questions are multiple-choice questions). The interface displays the stem of the first question and four options. The user selects one of the four options and submits it. The interface displays the second question,... Until the last question;
6. After the last question is submitted, the score is displayed on the interface, and the score is calculated according to the percentage of correct answers;
7. In the score interface, the user can choose to exit or continue to do questions;

2, Code reuse

1. Generate test paper

Generate questions according to the type and quantity of questions selected by the user (example):
The return value is added to the function. The function returns an array of strings. Each string represents a topic. The passed in parameters are the topic type, the path to save the topic and the number of topics

public static String[] GenerateTest(String type, String path, int number)

2. Generate suffix expression

The code is as follows (example):

int num = (int) (0 + Math.random() * (4 - 0 + 1));   //Get 0-4 binary operators
            ArrayList<String> houzhui = new ArrayList<>();
            int operands = (int) (1 + Math.random() * (100 - 1 + 1)); //The value range of operands is 1-100
            houzhui.add(Integer.toString(operands));

Randomly generate binary operators and operands, and then splice them into suffix expressions. According to the type of topic, unary operators such as root sign are inserted immediately

3. Translate suffix expression into infix expression

Through the stack, take the string from the suffix expression, and decide whether to enter or exit the stack according to the content of the string

//Translate suffix expression into infix expression
            Stack<String> stack = new Stack<>();
            int time=0;
            for (String str:houzhui){
                if (str.equals("sin")||str.equals("cos")||str.equals("tan")||str.equals("√")||str.equals("²")){
                    String popB=stack.pop();
                    if (str.equals("√")){
                        stack.push("√"+"("+popB+")");
                    }
                    if (str.equals("²")){
                        stack.push("("+popB+")"+"²");
                    }
                    if (str.equals("sin")){
                        stack.push("sin"+"("+popB+")");
                    }
                    if (str.equals("cos")){
                        stack.push("cos"+"("+popB+")");
                    }
                    if (str.equals("tan")){
                        stack.push("tan"+"("+popB+")");
                    }
                }
                else if(str.equals("+")||str.equals("-")||str.equals("*")||str.equals("/")){
                    String popB=stack.pop();
                    String popA=stack.pop();
                    if (str.equals("+")){
                        if (time==0){
                            temp = temp + "(" + popA + "+" + popB + ")";
                            time++;
                        }
                        else{
                            temp = "(" + temp + "+" + popB + 

Posted by pengu on Thu, 12 May 2022 07:28:28 +0300